Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Java Netbeans Database Connectivity

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
18,010
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jun 23, 2011

Hello Friends,
This Video is a tutorial which will assist you to connect Java Netbeans with MySQL and Access....for the database connectivity.......
To download MySQL /J Connector.tar.......

http://dev.mysql.com/downloads/connector/j/

Syntax:
.........................................

Coding at the top of Source window :-

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;



Coding for the JButton :-

DefaultTableModel model=(DefaultTableModel)p1.getModel(); try{ Class.forName("java.sql.Driver"); Connection conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/menage­rie","root","sql"); Statement st=conn.createStatement(); String query="Select * from dept;"; ResultSet rs=st.executeQuery(query); while(rs.next()){ String d1=rs.getString("deptno"); String d2=rs.getString("dname"); String d3=rs.getString("loc"); model.addRow(new Object[]{d1,d2,d3}); } rs.close(); st.close(); conn.close(); } catch(Exception e){ JOptionPane.showMessageDialog(this,e.getMessage()); }



............
Enjoy Connectivity!




For more information ,mail me at "psvalent05@yahoo.com"


or you can visit "http://parmindersinghblog.tk/" ............


Also join Netbeans community on Facebook
http://www.facebook.com/pages/Netbeans/157752054294728

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (05psvalent)

  • hi,

    can you please tell me what is with your "menagerie" in your url? i saw that it is your database..but can you tell me where can i find my database name?i get an exception Unknown database. Thanks.

  • @babadochiamusic

    Actually I have used MySQL for database connectivity here... The database in my case is menagerie....u can use MS Access also for the same... u must properly make a database and then carefully follow the steps as explained in the video....

    further to make a database

    type in the MySQL console...

    create database menagerie

    then u can make some tables in it ...

    After that connect it with Java Netbeans.....

    If u won't succeed in ur attempt ask me here

  • thanks a ton :D this is the most clear and easy understandable video tutorial for mysql database connectivty ... i tried every step but did not connect it showed some symbol pointing to import java.sql.*; line when i change that  to import com.mysql.jdbc.Connection;

    import com.mysql.jdbc.ResultSet;

    it ran successfully but showed error in connectivity after pressing fetch data button ..please help

  • @afsar786100

    OK ,So Afsar ...Do one thing .....write there Class.forName("com.mysql.jdbc.­Driver"); in place of Class.forName("java.sql.Driver­");

  • @afsar786100

    MoreOver u hav to import all the four database connection entities....that are connection,Statement,ResultSet­,DriverManager.........

    Other problem I may figure out is may be u shud download the MySQL Connector/J again and then add it in ur library of the project...OK......The link is there in the Description.........and the coding given in the description is also genuine.......So .....Gud luck ,,,if u again get any problem......ask me....anytime.....

  • thanx it helped a lot!

  • @shobhik1 Anytime dear

see all

All Comments (11)

Sign In or Sign Up now to post a comment!
  • @05psvalent works!!thank you so much

  • thaaaaaaaaaaaaaaaaaaaaaaaaaaaa­aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa­aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa­aaaaaaaaaaanks

    veeeeeeeeeeeeeeeeeeeeeery much

  • @09:53 in the url the derby is because of *Driver Name* field. If you change "Java DB (Network)" to "MySQL (Connector/J driver)" from the list, the derby will change to mysql in the URL.

  • Thanks, this was very helpful!

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more