Topic: 我为什么连不上数据库 |
Print this page |
1.我为什么连不上数据库 | Copy to clipboard |
Posted by: syl000 Posted on: 2005-04-20 12:39 <%@ page contentType="text/html;charset=GB2312"%> <%@ page import="java.sql.*"%> <html> <body> <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student"; //pubs为你的数据库的 String user="sa"; String password="13722304382"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from admin"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1)%> <%out.print("<br>"); %> 您的第二个字段内容为:<%=rs.getString(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html> 为什么连不上,那位高手帮一下忙,十分感谢!!! |
2.Re:我为什么连不上数据库 [Re: syl000] | Copy to clipboard |
Posted by: why Posted on: 2005-04-20 21:32 There are so many possible reasons that you 连不上M$SQL数据库 Please show us the error messages, if any. You may want to test the JDBC connection with a simple Java program first. |
3.Re:我为什么连不上数据库 [Re: syl000] | Copy to clipboard |
Posted by: xhxasdf Posted on: 2005-04-29 15:13 数据库驱动有没有装载?? |
4.Re:我为什么连不上数据库 [Re: syl000] | Copy to clipboard |
Posted by: keen_dai Posted on: 2005-05-11 14:43 please add error message |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |