Four. Run http://localhost/Select.jsp, display the results as follows:
User-list
1 corebit
2 Ivan
Indicates that the database connection was successful! Congratulations! Congratulations!
Otherwise, check the data source related settings, the likelihood of error is higher!
Postscript:
People often ask, how to do not do ODBC data source to let JSP access to the Access database, in order to unlock this mystery, close-up of the following connection code for reference! Among them, Jcc.mdb and select.jsp are located under the <%wwwroot%> (root directory).
After rewriting the select.jsp source code is as follows:
The running result should be the same as when using ODBC!
* Note: filename select.jsp case Sensitive!
Hopefully this article will help you with your JSP connection to the Access database!
==========================================
Only use the Jdbc-odbc bridge to connect
You want to set up an ODBC data source
And then connect
String dbdriver = "Oracle.jdbc.driver.OracleDriver";
String dbname = "JDBC:ORACLE:THIN:@192.168.0.101:1521:ORCL";//Modify according to your circumstances
String user = "System";//user name
String Password = "manager";//Password
Connection conn = null;
Statement stmt = null;
ResultSet RS =null;
String sql= "select * from table name";//modified according to the actual situation
Try
{
Class.forName (Dbdriver);
}
catch (Java.lang.ClassNotFoundException e) {
System.err.println ("Class Access_dbconnect not fount!" +e.getmessage ());
}
Conn=drivermanager.getconnection (Dbname,user,password);
Statement stmt=conn.createstatement ();
Rs=stmt.executequery (SQL);
=========================================
Sdbdriver = "Sun.jdbc.odbc.JdbcOdbcDriver";
sConnStr = "Jdbc:odbc:odbc name";
conn = null;
rs = null;
Try
{
Class.forName (Sdbdriver);
}
conn = Drivermanager.getconnection (SCONNSTR);
Statement Statement = Conn.createstatement ();
rs = Statement.executequery (s);
You build an Access connection in an ODBC data source, and then change the ODBC name in the above code to your ODBC data source connection name.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.