在odbc数据源设置好后采用如下方式访问,数据源名为test
String driver;
try
{
driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver).newInstance();
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}

try
{
sql = DriverManager.getConnection"jdbc:odbc:model", "user", "pass");
}
catch(SQLException e)
{
System.out.println("Database connection failed!");
System.out.println(e.getMessage());
System.exit(1);
}

解决方案 »

  1.   

    WebLogic开发了SQL Server 的JDBC Type 4驱动API.不过要钱的。
    DB2 对Java支持得很好。
      

  2.   

    我用JDBC访问过Oracle。连接,执行SQL,处理数据,写库。
      

  3.   

    请问各位JDBC   的驱动可以从哪里得到?
      

  4.   

    以db2为例:
    Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();//创建驱动程序实例
    Connection connection = DriverManager.getConnection(getDbUrl(), getDbUser(), getDbPassword());//建立与数据库的连接(db位置,user,pass)
                CallableStatement callableStatement1; //
                String sql="(call BBTJ_PS_SJJY(?,?,?,?))";
    callableStatement1 = connection.prepareCall (sql);
                callableStatement1.registerOutParameter(3, Types.INTEGER);
                callableStatement1.registerOutParameter(4, Types.REAL);
                callableStatement1.setString(1, s);
                callableStatement1.setString(2, s1);
                callableStatement1.execute();
                setSj_Jybs(callableStatement1.getInt(3));
       setSj_Je(callableStatement1.getFloat(4));
                callableStatement1.close();
                connection.close();
                return;
      

  5.   

    到http://java.sun.com搜索Docs,就可以找到你所需要的所有文档资料