你必须先设置环境变量:CLASSPATH=.;c:\jConnect-5_2\classes\jconn2.jarClass.forName("com.sybase.jdbc2.jdbc.SybDriver"); //for jconnect5.2
//Class.forName("com.sybase.jdbc.SybDriver"); //for jconnect4.2
println("Object init success.");
//Properties props = new Properties();//connect with Properties Method
//props.put("user","sa");
//props.put("password","passwd");
//Connection Con=DriverManager.getConnection("jdbc:sybase:Tds:131.107.126.1:5000",props);
Connection Con=DriverManager.getConnection("jdbc:sybase:Tds:131.107.126.1:5000","sa","passwd");
println("sybase connect success.");
Statement Stmt=Con.createStatement();
boolean restype=Stmt.execute("use mydb");
if(restype)
{
Stmt.cancel();
Stmt.close();
throw new SQLException("Unexpected results from USE");
}
println("use mydb success.");