jsp链接数据库,tomcat不会报错,帮看看哪里错了
<body>
<%
Connection conn=null;
Statement stmt=null;
String driver="com.microsoft.sqlserver.jdbc.sqlserverDriver";
String username="sa";
String password="d2009";
String sql=null;
String url="jdbc:sqlserver://172.20.1.5:1433;DatabaseName=MPL";
try{
System.out.print("加载之前");
Class.forName("COM.MICROSOFT.sqlserver.jdbc.SQLSERVERDriver");
System.out.println("connection successful!");
}
catch(ClassNotFoundException e){
System.out.print(e);
}
try{
System.out.print("加载之前");
conn=DriverManager.getConnection(url,username,password);
System.out.println("connection successful!");
}
catch(SQLException ee){
System.out.print(ee);
}
%>
</body>
运行之后显示空白
[解决办法]
catch(Exception ee){
System.out.print(ee);
}
改成捕捉 所有异常试试 O(∩_∩)O~
[解决办法]
你这页面什么都没写 当然就是什么也显示不了
将System.out.print 直接换成out.print 就能看到效果了
[解决办法]
<body><% Connection conn=null; Statement stmt=null; String driver="com.microsoft.sqlserver.jdbc.sqlserverDriver"; String username="sa"; String password="d2009"; String sql=null; String url="jdbc:sqlserver://172.20.1.5:1433;DatabaseName=MPL"; try{ out.print("加载驱动之前<br />"); Class.forName("COM.MICROSOFT.sqlserver.jdbc.SQLSERVERDriver"); out.println("load DB driver successful!"); out.println("连接之前<br />"); conn=DriverManager.getConnection(url,username,password); out.println("connection successful! <br />"); }catch(Exception e){ out.print(e + "<br />"); }%></body>
[解决办法]
你要把异常显示出来看看就知道了。
[解决办法]
不是告诉你需要换个驱动包了么。