0
我無法毫秒的存取連接我的jsp頁面 它說無法使用的MS Access連接我的jsp頁面
"java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
我創建了一個DSN,但仍然問題是一樣..
我搜查了淨廣泛,但不能糾正....
DriverManager.getConnection("jdbc:odbc:students");
此行是造成異常.... 我選擇了DNS仍數據源太....我米使用Access ....
這裏的一切:
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
PreparedStatement pstm;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//connection object created using DriverManager class
//employee is the name of the database
Connection connect =DriverManager.getConnection("jdbc:odbc:employee");
//creating prepared statement object pstm so that query can be sent to database
pstm=connect.prepareStatement("insert into employee values(?,?,?,?)");
pstm.setString(1,"5");
pstm.setString(2,"parth");
pstm.setString(3,"parth");
pstm.setString(4,"10000");
//execute method to execute the query
pstm.executeUpdate();
out.println("Record Added Successfully");
pstm.close();
connect.close();
%>
</body>
</html>