各位大大,我刚接触jsp,想先从数据库入手,可是老是编译不过,请帮忙看看,谢谢!我已经在错误的地方用"//"做了说明
--------------------------------------------------------------------------
package user ;
import java.sql.*;
Connection conn= null ; //说我这里有错误,意思是没有声明Connection属于哪个类,有个java.sql不是就OK了的么?
ReseltSet rs = null ; //同上
String Username = "" ; //同上
String Password = "" ; //同上
String Email = "" ; //同上
String Homepage = "" ; //同上
public db () {
try {
Class.forName (" sun.jdbc.odbc.JdbcOdbcDriver ") ;
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public ResultSet executeQuery ( String sql ) {
try {
//如果我把Connection conn放在这里就没有问题,真是奇怪!!!
conn = DriverManager.getConnection("jdbc:odbc:demodb") ;
Statement stmt = conn.creteStatement();
rs = stmt.executeQuery(sql);
}
catch ( Exception e ) {}
return rs ;
}
public boolean executeUpdate ( String sql ) {
boolean bupdata = false ;
rs = null ;
try {
conn = DriverManager.getConnection("jdbc:odbc:demodb") ;
Statement stmt = conn.creteStatement();
int rowCount = stmt.executeQuery(sql);
if ( rowCount!=0 )
bupdate = true ;
}
catch ( Exception e ) {}
return bupdate ;
}
public static String toChinese ( String strvalue ) {
try {
if ( strvalue == null )
{
return null ;
}
else
{
strvalue = new String (strvalue.getBytes("ISO8859_1"),"GBK");
return strvalue;
}
}
catch( Exception e ) {
return null ;
}
}}
PS:我是想上面的东西做成一个javabean 可编译通不过
[此贴子已经被作者于2006-3-27 12:17:23编辑过]