主题:jsp 连 sql server 的 问题
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>
test
</title>
</head>
<body bgcolor="#ffffff">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:sqldsn","pubs","aa");
//String user="sa";
//String password="";
//Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql="insert into aa values('cc','dd')";
ResultSet rs=stmt.executeQuery(sql);
//while(rs.next()){%>
<%out.print("shu ju ku cao zuo cheng gong");%>
<%
rs.close();
stmt.close();
conn.close();
%>
<h1>
JBuilder Generated JSP
</h1>
</body>
</html>
aa 是建在pubs下的一个表,有两个字段,数据类型是varchar型.
异常是:javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'aa' 无效。
odbc数据源是:sqldsn
<%@ page import="java.sql.*"%>
<html>
<head>
<title>
test
</title>
</head>
<body bgcolor="#ffffff">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:sqldsn","pubs","aa");
//String user="sa";
//String password="";
//Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql="insert into aa values('cc','dd')";
ResultSet rs=stmt.executeQuery(sql);
//while(rs.next()){%>
<%out.print("shu ju ku cao zuo cheng gong");%>
<%
rs.close();
stmt.close();
conn.close();
%>
<h1>
JBuilder Generated JSP
</h1>
</body>
</html>
aa 是建在pubs下的一个表,有两个字段,数据类型是varchar型.
异常是:javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'aa' 无效。
odbc数据源是:sqldsn