简体   繁体   English

JDBC getconnection在Mac上不起作用

[英]JDBC getconnection doesn't work on mac

Hi I recently updated the java version on my mac to 1.6.0_29 and now the following line continually causes my program to crash. 嗨,我最近将Mac上的Java版本更新为1.6.0_29,现在以下行不断导致我的程序崩溃。 Java does not throw an error it just runs endlessly and i have to force close it. Java不会抛出错误,它只会无休止地运行,我必须强制关闭它。 The program works fine on my windows 7 pc so I am relatively sure that this bug has to do with the new update. 该程序在Windows 7 PC上可以正常运行,因此我相对确定此错误与新更新有关。

conn = DriverManager.getConnection(conurl, user, pass);

This is the function I have written along with my my driver. 这是我与驱动程序一起编写的功能。 I am using sqljbdc4. 我正在使用sqljbdc4。

public static Connection dbCon(String conurl, String user, String pass, String db) throws SQLException, ClassNotFoundException{
    String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    Connection conn;
    Statement stmt;
    String sql;
    Class.forName(JDBC_DRIVER);
    conn = DriverManager.getConnection(conurl, user, pass);
    stmt = conn.createStatement();
    sql = "USE "+db;
    stmt.executeUpdate(sql);
    return conn;
}

I've had success on Java 1.6 using the JTDS driver . 我已经使用JTDS驱动程序在Java 1.6上取得了成功。 I'm personally using Linux, but have a coworker using the same driver on his MacBook. 我个人使用的是Linux,但有一个同事在MacBook上使用相同的驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM