<%@ 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=Jac";
//mydb为数据库
String user="sa";
String password="565689";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String sql="select * from C";ResultSet rs=stmt.executeQuery(sql);while(rs.next()){%>您的第一个字段内容为:<%=rs.getString(1)%>您的第二个字段内容为:<%=rs.getString(2)%><%}%><%out.print("数据库操作成功,恭喜你");%><%rs.close();stmt.close();conn.close();%></body></html>
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Jac";
//mydb为数据库
String user="sa";
String password="565689";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String sql="select * from C";ResultSet rs=stmt.executeQuery(sql);while(rs.next()){%>您的第一个字段内容为:<%=rs.getString(1)%>您的第二个字段内容为:<%=rs.getString(2)%><%}%><%out.print("数据库操作成功,恭喜你");%><%rs.close();stmt.close();conn.close();%></body></html>
http://dev.csdn.net/article/70/70360.shtm
这里有详细的解决方案
http://dev.csdn.net/article/70/70360.shtm
里面的修改了 可是还有错误
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /sql_test.jsp(1,4) Invalid directive
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:506)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.不知道怎么办才好
2)在相应"数据库"上单击右键,选择"属性"
3)选择"连接"选项卡,检查"远程服务器连接"下,RPC服务是否选择.我的数据库里没有3)中的“连接”选项卡呀,找不到“远程服务器连接”啊