20分求JSP网络编程从基础到实践邓子云解决方法

来源:百度知道 编辑:UC知道 时间:2024/06/15 02:05:37
邓子云写的书里面有个实力是学生成绩管理系统里面连接数据库代码如下
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.io.InputStream;
import java.util.Properties;
/**
* 数据库连接类
* @author 邓子云
*/
public class dbconn {
String driverName="sun.jdbc.odbc.JdbcOdbcDriver";//数据库驱动名
String connString="jdbc:microsoft:sqlserver://localhost:1433";//连接字符串
String userName=sa;//用户名
String password=sa;//密码
String propertyFileName=student;//.properties文件名称
public dbconn() {
}
public Connection getDBConn()
{//得到数据库连接对象
this.setPropertyFileName("/dbconn.properties");
driverName=this.getPropertyFromFile("driverName");
connString=this.getPropertyFromFile("connString");
userName=this.getPropertyFromFile("userName");
password=this.getPropertyFromFile("password");
if(driverName==null||conn

1
String userName="sa";//用户名
String password="sa";//密码
String propertyFileName="student";//.properties文件名称

就是加上双引号,

2还有在程序根目录加上一个名为student 的properties文件

3 String driverName="sun.jdbc.odbc.JdbcOdbcDriver";//数据库驱动名
String connString="jdbc:microsoft:sqlserver://localhost:1433";//连接字符串

改成自己的驱动类,哪种数据库连接字符串,别忘了添加jdbc驱动jar包

哪不好使了 谁知道我奖励 40分

(__)
/oo\\________
\ / \---\
\/ / \ \
\\_|___\\_|/ *
|| YY|
|| ||