无法连接到NetBeans中的MySql数据库给出异常

时间:2014-02-23 16:45:56

标签: java mysql netbeans jdbc

我正在尝试连接java中的MySQL数据库。我从MySQL下载了连接器驱动程序(它叫做“mysql-connector-java-5.0.8-bin.jar”),我添加到我的库(我使用NetBeans)。但它的Giving Exception如下:((错误...... java.lang.ClassNotFoundException:com.mysql.jdbc.Driver))请帮帮我

 public void DryAirEntry() throws SQLException
{
    Connection con=null;
    try
    {
       Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/coolingSystem","test","password");
        String str = "insert into dryAir_properties values(NULL,"+txt_T_a.getText()+","+txt_Cp_a.getText()+","+txt_k_a.getText()+","+txt_Viscosity_D_a.getText()+","+txt_Density_a.getText()+")";
        PreparedStatement ps = con.prepareStatement(str);
        ps.executeQuery();
    }catch(ClassNotFoundException | SQLException e)
            {
                System.out.println("Error......"+e.getMessage());
            }
}

0 个答案:

没有答案