How to connect NetBeans to MySQL database?

前端 未结 6 1870
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 03:08

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条回答
  •  余生分开走
    2020-12-17 03:24

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

提交回复
热议问题