当前位置: 技术问答>java相关
急!!急!!我的数据库连接怎么是这样的问题!!!
来源: 互联网 发布时间:2015-06-23
本文导语: 我做了一个jsp程序,我用javaBean封装连接数据库的事务。 我的平台为:win2000+resin-2.0.4+jdk1.3 运行后出错如下: 浏览其中出错为: 500 Servlet Exception java.lang.NullPointerException at _kcsj._register2__jsp._jspService(/kcsj/register2.jsp...
我做了一个jsp程序,我用javaBean封装连接数据库的事务。
我的平台为:win2000+resin-2.0.4+jdk1.3
运行后出错如下:
浏览其中出错为:
500 Servlet Exception
java.lang.NullPointerException
at _kcsj._register2__jsp._jspService(/kcsj/register2.jsp:29)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:176)
at com.caucho.server.http.Invocation.service(Invocation.java:278)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
at com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:847)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.4 (built Thu Nov 15 17:56:24 PST 2001)
Resin窗口中显示说:aq.executeQuery:No suitable driver
那个高手能告诉我为什么吗!小弟很急很急啊!!!
-------------------------------------------------------------------
源代码如下:(处理注册信息的写入数据库)
register
0)//用户已经存在
{
%>
该用户已经存在注册
----------------------------------------------------------------------
Club_dbconnect.java的源代码如下:
package Club;
import java.sql.*;
import java.io.*;
public class Club_dbconnect {
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc.odbc:soft";
Connection conn=null;
ResultSet rs=null;
public Club_dbconnect() {
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("Class Club_dbconnection not found!"+e.getMessage());
}
}
//数据查询部分
public ResultSet executeQuery(String sql){
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
//数据更新
public ResultSet executeUpdate(String sql){
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
}
我的平台为:win2000+resin-2.0.4+jdk1.3
运行后出错如下:
浏览其中出错为:
500 Servlet Exception
java.lang.NullPointerException
at _kcsj._register2__jsp._jspService(/kcsj/register2.jsp:29)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:176)
at com.caucho.server.http.Invocation.service(Invocation.java:278)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
at com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:847)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.4 (built Thu Nov 15 17:56:24 PST 2001)
Resin窗口中显示说:aq.executeQuery:No suitable driver
那个高手能告诉我为什么吗!小弟很急很急啊!!!
-------------------------------------------------------------------
源代码如下:(处理注册信息的写入数据库)
register
0)//用户已经存在
{
%>
该用户已经存在注册
----------------------------------------------------------------------
Club_dbconnect.java的源代码如下:
package Club;
import java.sql.*;
import java.io.*;
public class Club_dbconnect {
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc.odbc:soft";
Connection conn=null;
ResultSet rs=null;
public Club_dbconnect() {
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("Class Club_dbconnection not found!"+e.getMessage());
}
}
//数据查询部分
public ResultSet executeQuery(String sql){
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
//数据更新
public ResultSet executeUpdate(String sql){
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
}
|
JDBC 驱动没找到!
|
No suitable driver
说明在你的classpath种没有jdbc驱动
你把它加入到classpath种就可以了
说明在你的classpath种没有jdbc驱动
你把它加入到classpath种就可以了