主题:已解决
麻木阿瓜
[专家分:0] 发布于 2006-11-19 12:51:00
conn=DriverManager.getConnection([color=FF0000]url,"","");[/color]
括号里的格式怎麽写?
回复列表 (共7个回复)
沙发
麻木阿瓜 [专家分:0] 发布于 2006-11-18 23:21:00
对了 Tomcat里是这麽说的
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /test.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\test_jsp.java:60: cannot find symbol
symbol : variable url
location: class org.apache.jsp.test_jsp
conn=DriverManager.getConnection(url,"scott","tiger");
板凳
dingsl1983 [专家分:40] 发布于 2006-11-18 23:24:00
user,password
3 楼
dingsl1983 [专家分:40] 发布于 2006-11-18 23:25:00
即你的数据库用户名和密码。我的sa,123
4 楼
麻木阿瓜 [专家分:0] 发布于 2006-11-18 23:28:00
我没设密码 要写null吗?
5 楼
麻木阿瓜 [专家分:0] 发布于 2006-11-18 23:32:00
那个
你所说的数据库是在哪里啊
我以为在C:\Program Files\Common Files\ODBC目录下的放数据的文件名就是数据库名
不过好像很不对劲
6 楼
yexin218 [专家分:4070] 发布于 2006-11-19 09:03:00
protected String driverName = "com.mysql.jdbc.Driver";
protected String dbURL = "jdbc:mysql://localhost:3306/sample_db";
protected String userID = "root";
protected String passwd = "password";//your sql's password
Class.forName(driverName);
dbConnection = DriverManager.getConnection(dbURL,userID,passwd);
Statement stmt = dbConnection.createStatement();
7 楼
麻木阿瓜 [专家分:0] 发布于 2006-11-19 09:15:00
[em17]看不太懂
我是按书上来的:
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}
try{
conn = DriverManager.getConnection("jdbc:odbc:shiyan");
stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
我按照书上把jdbc:odbc:shiyan填了进去
问题就没了 可是出现了新的问题
好像是说驱动不合适:
javax.servlet.ServletException: No suitable driver
可是 我完全是按书上作的呀
我来回复