<b>JavaBean 实例</b>[Java编程]
本文“<b>JavaBean 实例</b>[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
package untitled1;
import java.sql.*;
public class Jsp2Bean {
private String sample = "Start value";
String strDBDtiver="sun.jdbc.odbc.JdbcOdbcDriver";
String strConn ="jdbc:odbc:unititled1";
Connection conn=null;
ResultSet rs = null;
//Access sample property
public String getSample() {
return sample;
}
//Access sample property
public void setSample(String newValue) {
if (newValue!=null) {
sample = newValue;
}
}
public Jsp2Bean(){
try{
Class.forName(strDBDtiver);
}
catch(java.lang.ClassNotFoundException e){
System.out.println("DataBase Open Error : " + e.getMessage());
}
}
public ResultSet exeCuteQuery(String strSQL){
rs=null;
try{
conn = DriverManager.getConnection(strConn);
Statement stmt = conn.createStatement();
rs= stmt.executeQuery(strSQL);
}
catch(java.sql.SQLException ex){
System.out.println("SQL RUN ERROR : " + ex.getMessage());
}
return rs;
}
}
以上是“<b>JavaBean 实例</b>[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |