Class.forName(oracle-driver);
Class.forName(sybase-drvier);Connection c1 = DriverManager.getConnection(oracle-url);
Connection c2 = DriverManager.getConnection(sybase-url);

解决方案 »

  1.   

    楼上的兄弟有什么依据说不行?我倒是做了一个测试验证是可行的。
    我手头没有sybase,用mysql代替了。
    public class TestConnection extend TestCase {
        static {
            try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                Class.forName("com.mysql.jdbc.Driver");
            } catch(Exception ex) {throw new RuntimeException(ex);}
        }    public TestConnection(String name) {super(name);}    public void testConn() throws SQLException {
            Connection c1 = DriverManager.getConnection("jdbc:mysql://localhost/mysql", "root", "root");
            Connection c2 = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:goblin", "system", "manager");        assertNotNull(c1);
            assertNotNull(c1);        c1.close();
            c2.close();
        }
    }
      

  2.   

    BUG FIX:
    assertNotNull(c1);
    assertNotNull(c2);
      

  3.   

    我搞过将MS SQLSERVER 和MYSQL一起注册,但是建立连接的时候我只用了一个Connection,从一个数据库读数据,然后写到另外一个数据库里面去,读完以后将Connection给null,然后在获得一个Connection,可以正常工作,所以我想,同时建立两个Connection对象也是可以工作的
      

  4.   

    // Load Mysql's JDBC Driver //String driver="org.gjt.mm.mysql.Driver";
    String driver="com.mysql.jdbc.Driver";
    try { 
    Class.forName(driver).newInstance();
    }
    catch(Exception se) { 
    System.out.println(se); 
    } // Load Sybase's JDBC Driver driver="com.sybase.jdbc2.jdbc.SybDriver";
    try { 
    Class.forName(driver).newInstance();
    }
    catch(Exception se) { 
    System.out.println(se); 
    } // Remote mysql server
    String url = "jdbc:mysql://xxx.xxx.xxx.xxx:3306/test?useUnicode=true&characterEncoding=gbk";
    String user = "xxx";
    String password = "xxx";
    Connection connRemoteMysql = DriverManager.getConnection(url, user, password);// Local mysql server
    url = "jdbc:mysql://localhost:3306/sunnywest?useUnicode=true&characterEncoding=gbk";
    user = "xxx";
    password = "xxx";
    Connection connLocalMysql = DriverManager.getConnection(url, user, password);//      Remote sybase server of hy
    url="jdbc:sybase:Tds:xxx.xxx.xxx.xxx:5000/hy?useUnicode=true";
    user="xxx";
    password="xxx";
    Connection connRemoteSybase = DriverManager.getConnection(url, user, password);