当前位置: 技术问答>java相关
不吝加分噢!用Java连接PB中自带的Adaptive Server Anywhere数据库怎么做?
来源: 互联网 发布时间:2015-05-07
本文导语: 那位大虾给个例子,是用ODBC连接,还是要下载驱动程序? 加分加分加分………… | import java.util.Properties; import java.sql.*; public class con { public static void main(String args[]) { String driverName =...
那位大虾给个例子,是用ODBC连接,还是要下载驱动程序?
加分加分加分…………
加分加分加分…………
|
import java.util.Properties;
import java.sql.*;
public class con
{
public static void main(String args[])
{
String driverName = "sum.jdbc.odbc.JdbcOdbcDriver"
String sourceURL = "jdbc:odbc:ASA 6.0 Sample"
try
{
Class.forName(driverName);
Properties prop = new Properties();
prop.setProperty("user","dba");
prop.setProperty("password","sql");
Connection databaseConnection = DriverManager.getConnection(sourceURL,prop);
}
catch(ClassNotFoundException cnfe)
{
System.err.println("Error loading"+driverName);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}
}
要記得給分。
import java.sql.*;
public class con
{
public static void main(String args[])
{
String driverName = "sum.jdbc.odbc.JdbcOdbcDriver"
String sourceURL = "jdbc:odbc:ASA 6.0 Sample"
try
{
Class.forName(driverName);
Properties prop = new Properties();
prop.setProperty("user","dba");
prop.setProperty("password","sql");
Connection databaseConnection = DriverManager.getConnection(sourceURL,prop);
}
catch(ClassNotFoundException cnfe)
{
System.err.println("Error loading"+driverName);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}
}
要記得給分。