7

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.

1
  • Is your question about using the built in NetBeans SQL editor to access your database, or are you asking how to connect the program that you've written to a MySQL database? Commented May 22, 2011 at 10:11

6 Answers 6

11

In the Services window you can right click on the Databases tab and select New Connection. 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. Driver Information

Finally enter your database details such as servername, username and password and click finish. Database Details

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

2

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

5 Comments

@jigar u don't need to install jar. just select connetor/J dirver
@ravi I meant installation by that
@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.....
buddy u have to attache mysql.jar to run your project library. attache with naetbean is just like workbench,querybrowser, toad etc.
You need to provide driver jar into classpath
1

click on window and then select services

enter image description here

then click on databases and select new connection enter image description here

select driver which you want

enter image description here

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());
    }

Comments

0

see mysql .jar for u project properties if u waant to run or for netbeans shown by @Vincent Ramdhanie enter image description here

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.