那明显是sDBDriver有问题,为什么还用odbc
解决方案 »
- 怎样方便的在一个页面测试服务器的运行情况
- javax.servlet.ServletException: java.lang.NullPointerException问题
- hibernate连接数据库问题(在线等呀,谢谢个位大狭)
- xsl如何解析单选框、复选框、下拉列表
- TOMCAT 中怎么部署HIBERNATE程序?
- JAVA应用程序最多只能用到1G内存吗?
- 求助:在jboss中部署jsp的问题?
- sql 数据库的典型配置应该如何写??
- 请教各位大侠关于使用RMI中出现的错误:java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception
- 上传文件
- 谈谈 Stucts 的优缺点
- 请教一下MiddleGen和hbm2java的问题!
---------------------------------
catch(java.lang.ClassNotFoundException e)
System.err.println(e.getMessage() ); //<------提示我这里有错误.
}
--------------------------------------
好像少了个括号呢还catch(java.lang.ClassNotFoundException e)后面
你运用JDBC-ODBC 桥连接的话,
首先 装驱动
在打开连接这个千古道理你要清楚,
在就是看 看你的 字符串和 创建的连接 Statement 等等这些细节对否?
这个都是死东西,很好找的 你要静下心来找,一定清楚,这个很重要,也很基本的!
祝你好运!
{
public static Connection GetConnection()
{
Connection con = null;
String classforname ="oracle.jdbc.driver.OracleDriver";
String url="jdbc:odbc:odbcsource";
String user = "user";
String pwd = " ";
try{
//转载驱动,每个数据库驱动程序都必须实现Driver接口;
class.forName(classforname);
//调用DriverManager的getConnection()连接到指定的数据库;
con = DriverManager.getConnection(url,user,pwd);
}
catch(excepton e)
{
e.printStactTrance();
}
return con;
}
} class ExeSql
{
public ExeSql()
{
try
{
Connection con= null;
con = DataBaseConnection.GetConnection()
}
catch(exception e)
{
e.printStackTrace(); }
} public ResultSet ExecuteQuery()
{
try{ Connection con = DataBaseConnection.GetConnection()
Statement stmt = null;
ResultSet rst = null;
String sql="select * from tablename where a =b "
rst = stmt.executeQuery("sql");
reture rst;
Close();
}
catch(exception e)
{
e.printStackTrace();
}
}
public int ExecuteUpdate()
{
try
{
Connection con = DataBaseConnection.GetConnection()
Statement stmt = null;
int rst =0;
String sql="update tablename set a = b where a = c "
rst = stmt.executeQuery("sql");
return rst;
Close();
catch(exception e )
{
e.printStackTrace();
}
} public boolean Execute()
{
try{ Connection con = DataBaseConnection.GetConnection()
Statement stmt = null;
boolean rst=false;
String sql="select * from tablename where a =b "
rst = stmt.execute("sql");
return rst;
Close();
}
catch(exception e)
{
e.printStackTrace();
}
} public void Close()
{
if(con != null || stmt !=null)
con.close;
stmt.close;
}
}
{
public static Connection GetConnection()
{
Connection con = null;
String classforname ="oracle.jdbc.driver.OracleDriver";
String url="jdbc:odbc:odbcsource";
String user = "user";
String pwd = " ";
try{
//转载驱动,每个数据库驱动程序都必须实现Driver接口;
class.forName(classforname);
//调用DriverManager的getConnection()连接到指定的数据库;
con = DriverManager.getConnection(url,user,pwd);
}
catch(excepton e)
{
e.printStactTrance();
}
return con;
}
} class ExeSql
{
public ExeSql()
{
try
{
Connection con= null;
con = DataBaseConnection.GetConnection()
Statement stmt = null;
}
catch(exception e)
{
e.printStackTrace(); }
} public ResultSet ExecuteQuery()
{
try{
ResultSet rst = null;
String sql="select * from tablename where a =b "
rst = stmt.executeQuery("sql");
reture rst;
Close();
}
catch(exception e)
{
e.printStackTrace();
}
}
public int ExecuteUpdate()
{
try
{
int rst =0;
String sql="update tablename set a = b where a = c "
rst = stmt.executeQuery("sql");
return rst;
Close();
catch(exception e )
{
e.printStackTrace();
}
} public boolean Execute()
{
try{
boolean rst=false;
String sql="select * from tablename where a =b "
rst = stmt.execute("sql");
return rst;
Close();
}
catch(exception e)
{
e.printStackTrace();
}
} public void Close()
{
if(con != null || stmt !=null)
con.close;
stmt.close;
}
}
上面个有问题 呵呵,随手写的,三个月之前学的java 只后就做.net写这里参考下,有很多都想不起来,也没调试!