jdbc-odbc是数据库的连接一种,
首先要有安装jdk的安装包。其次就是要在管理工具建立数据源。
这个属于比较常见的一种连接方法。下面是一个jsp测试文件。
<%@ page language="java" import="java.sql.*" session="true" %>
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:setProperty name="user" property="*"/>
<html>
<head>
</head>
<body>
<h1>Query</h1>
<hr>
<%
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url ="jdbc:odbc:Northwind";
Connection con;
//ResultSet rs;
ResultSet rs;
Class.forName(driver);
con = DriverManager.getConnection(url,"sa","danlian");
Statement stmt = con.createStatement();
rs = stmt.executeQuery("Select * from Customers");
while(rs.next())
{
out.print("CustomerID:" + rs.getString("CustomerID") +"<br>");
}
%>
</body>
</html>
在tomcat5.5,jdk1.5,sql2k下通过测试
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}