Chinaunix
标题:
java连接odbc数据源
[打印本页]
作者:
cxz1980
时间:
2005-03-15 16:47
标题:
java连接odbc数据源
import java.sql.*;
public class DBTtest {
public DBTest() {
}
public Connection connection() throws SQLException{
Connection con=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(java.lang.ClassNotFoundException e){
System.err.println("Conneciton Function:"+" "+e.getMessage());
}
try{
con=DriverManager.getConnection("jdbc:odbc:jtest;uid=sa;pwd=");
}catch(SQLException ec){
System.err.println("getConnection Function:"+" "+ec.getMessage());
}
return con;
}
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/4357/showart_15762.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2