server里面连接数据库
public void openDatabase(String dsn) throws SQLException {
try {
// new sun.jdbc.odbc.JdbcOdbcDriver();Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");} catch (ClassNotFoundException e)
{System.out.println("Could not find sun.jdbc.odbc.JdbcOdbcDriver");throw new SQLException();}connection = DriverManager.getConnection("jdbc:odbc:" + dsn, null, null);statement = connection.createStatement();System.out.println("Connected to " + dsn);}
本文提供了一个使用Java通过ODBC连接特定数据源的示例代码,展示了如何加载驱动、建立连接及创建语句。
923

被折叠的 条评论
为什么被折叠?



