I have just installed NetBeans 7.0 and I am a newbie in NetBeans' world. can any one tell me how to connect my application to MySQl / Postgres ? I work on Windows XP.
6 Answers
In the Services window you can right click on the Databases tab and select New Connection.
Select MySQL(Connector/J Driver) from the drop down list. The driver file should be listed in the window. If not, you can download the file, then click add and select it from your hard drive.
Finally enter your database details such as servername, username and password and click finish.

- 102,349
- 23
- 137
- 192
If you meant you want to use IDE's GUI tool then
- windows > services >database > driver
- Get the driver jar
- install the jar
- right click on driver installed > connect using > and then provide the information
Or otherwise use JDBC

- 237,923
- 42
- 401
- 438
-
-
-
@ravi and @Jigar : I have done all that... but still Class.forName() is throwing ClassNotFoundException. When I tried System.setProperty("jdbc.driver","driver info"); still it is not working..... – Amit May 21 '11 at 11:55
-
buddy u have to attache mysql.jar to run your project library. attache with naetbean is just like workbench,querybrowser, toad etc. – Ravi Parekh May 21 '11 at 11:58
-
One way to connect to such databases is to use a JDBC (Java Database Connectivity) driver. You can find more about JDBC at the Oracle FAQ.

- 855
- 10
- 21
click on window and then select services
then click on databases and select new connection
select driver which you want
then click finish
if you want to check the connection is successful or not
try
{
con=DriverManager.getConnection("jdbc:mysql://localhost/student_result","root","");
JOptionPane.showMessageDialog(null,"connected with "+con.toString());
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"not connect to server and message is"+e.getMessage());
}

- 54,482
- 7
- 145
- 148
Follow the steps:-
1.Create a new application 2.In projects section of netbeans right click on libraries 3.Check the picture(i)Libraries java mysql connector Thus you successfully setup the connection with mysql.

- 1
see mysql .jar for u project properties if u waant to run or for netbeans shown by @Vincent Ramdhanie

- 5,253
- 9
- 46
- 58