帮我看看第二个JSP难题,确实调试不出来了。谢谢大家,(50分)

  • 主题发起人 主题发起人 billrobin
  • 开始时间 开始时间
B

billrobin

Unregistered / Unconfirmed
GUEST, unregistred user!
出错信息:
500 Servlet Exception
C:/resin-3.0.0-beta/MaterialOffice/WEB-INF/DataBase/DBConnection/DBConnection.java:5:
class DBConnManage is public, should be declared in a file named DBConnManage.java
public class DBConnManage
^
C:/resin-3.0.0-beta/MaterialOffice/WEB-INF/DataBase/DBConnection/DBConnection.java:9:
cannot resolve symbol
symbol : class Resultset
location: class DBConnection.DBConnManage
Resultset rs=null;
^
2 errors
源代码:
package DBConnection;
import java.sql.*;
import java.util.*;
public class DBConnManage
{
Connection conn=null;
Statement stmt=null;
Resultset rs=null;
String DBdriver="oracle.jdbc.driver.OracleDriver";
String DBLocation="jdbc:oracle:thin:@localhost:1521:CQMIS";
String DBUserID="cqsiyo";
String DBPasswd="robinsoft";
//构造函数。
public Statement ConnectionORADB()
{
try
{
Class.forName(DBdriver);
conn=DriverManager.getConnection(DBLocation,DBUserID,DBPasswd);
stmt=conn.createStatement();
}
catch(SQLException e)
{
System.err.println("DataBase Error:"+e.getMessage());
}
}
}

那位兄弟帮我看看,我最近对JAVA热情很高,正在努力学习,谢谢!!!
 
发现一个错误先
>>Resultset rs=null;
ResultSet rs=null;
 
呵呵,搞java就要看清大小写
 
>>//构造函数。
>>public Statement ConnectionORADB()
构造函数??是方法吧,怎么没有return?
 
修改后的程序:
package DBConnection;
import java.sql.*;
public class DBConnManage
{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String DBdriver="oracle.jdbc.driver.OracleDriver";
String DBLocation="jdbc:oracle:thin:@localhost:1521:CQMIS";
String DBUserID="cqsiyo";
String DBPasswd="robinsoft";

public Statement ConnectionORADB()
{
try
{
Class.forName(DBdriver);
conn=DriverManager.getConnection(DBLocation,DBUserID,DBPasswd);
stmt=conn.createStatement();
}
catch(SQLException e)
{
System.err.println("DataBase Error:"+e.getMessage());
}
return stmt;
}
}

还是出错,出错信息是:
500 Servlet Exception
C:/resin-3.0.0-beta/MaterialOffice/WEB-INF/DataBase/DBConnection/DBConnection.java:5:
class DBConnManage is public, should be declared in a file named DBConnManage.java
public class DBConnManage
^
C:/resin-3.0.0-beta/MaterialOffice/WEB-INF/DataBase/DBConnection/DBConnection.java:9:
cannot resolve symbol
symbol : class Resultset
location: class DBConnection.DBConnManage
Resultset rs=null;
^
2 errors

--------------------------------------------------------------------------------
Resin 3.0.0-beta (built Thu Feb 13 18:21:13 PST 2003)

我已注意大小写了,还是不行呀?出错信息还是一样的,我实在找不到原因了。可能是
我刚学JAVA。它的出错好象与:
public class DBConnManage
^
有关。这有什么关系吗?
第二个出错与:location: class DBConnection.DBConnManage
Resultset rs=null;
^
有关,我该怎么办呢?
 
修改后以下代码在我的IDE编译通过(GEL+WIN2K):
//package DBConnection;

import java.util.*;
import java.sql.*;
public class DBConnManage
{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String DBdriver="oracle.jdbc.driver.OracleDriver";
String DBLocation="jdbc:oracle:thin:@localhost:1521:CQMIS";
String DBUserID="cqsiyo";
String DBPasswd="robinsoft";

public Statement ConnectionORADB()throws ClassNotFoundException //<------
{
try
{
Class.forName(DBdriver);//forName可能会产生ClassNotFoundException
//必须进行异常处理,要么捕获(try/catch),要么在程序中指明该异常
conn=DriverManager.getConnection(DBLocation,DBUserID,DBPasswd);
stmt=conn.createStatement();
}
catch(SQLException e)
{
System.err.println("DataBase Error:"+e.getMessage());
}
return stmt;
}
}
 
1、文件名必须是 DBConnManage.java
2、ResultSet
^这里大写
 
to ZRWeng:
不好意思,因为我刚学JAVA,我还不知道GEL是什么?您能告诉我吗?
GEL是什么工具软件?
 
呵呵,是JAVA的一种IDE工具,你可以到
http://www.gexperts.com/
下载
 
to ZRWeng,
谢谢您,我将努力学习。我的QQ是:3131826,您的呢?我以前是用DELPHI的。三层结构
还行。希望能交个朋友。
 
呵呵,我的QQ是17263525,我也是用Delphi,三层不熟,JAVA也不怎么样
希望以后可以向你讨教 :)
我加了你~
 
接受答案,认定您这个兄弟了。
 
后退
顶部