jsp源程序
<%@ page language="java" import="java.sql.*"%>
<html>
<head>
</head>
<body>
<% String strurl="jdbc.odbc.qiao";
String sql;
String caption=request.getParameter("caption");
String content=request.getParameter("content");
//sql="insert into news(caption,content) values("+caption+","+content+")";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(strurl,"sa","");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate("insert into news(caption,content)values("+"'"+caption+"'"+","+"'"+content+"'"+")");
out.print( "executeSql------" );
}
catch(Exception e){
out.println( "executeSql-"+e.toString() );
}
%>
</body>
</html>
中间连接数据库的代码,我在JAVA程序中测试没有问题,但在JSP里面怎么也不行,用ACCESS数据库,一样,在JAVA中测试OK,在JSP里同样的错误提示。
请问为何?java.sql.SQLException: No suitable driver
------解决方法--------------------------------------------------------
你确信是在一样的环境里面运行的?看错误信息应该是驱动没有。
------解决方法--------------------------------------------------------
strurl有问题.
strurl = "jdbc:microsoft:sqlserver://192.*.*.*:1433;DatabaseName=qiao"
192.*.*.*: 换成你数据库地址.