(Z) Method for directly connecting Access data sources with Java

zhaozj2021-02-12  159

For settings with the JSP server under Windows, use Access is a better choice, but you should usually pass the data source using the Access database. Here is a method that does not directly connect the data source for Java using a data source. The example program is as follows: program code:

Import java.sql. *; public class access {public static void main (string args []) throws exception {string strunt = "JDBC: ODBC: driver = {Microsoft Access Driver (* .mdb)}; DBQ = D: / /projects//demo.mdb "; Class.forName (" sun.jdbc.odbc.JdbcOdbcDriver "); Connection conn = DriverManager.getConnection (strurl); Statement stmt = conn.createStatement (); ResultSet rs = stmt.executeQuery ( "Select * from mcp_swty_player"); while (rs.next ()) System.Out.println (Rs.getstring ("Player_Mobile"); rs.close (); stmt.close (); conn.close (); }

转载请注明原文地址:https://www.9cbs.com/read-7351.html

New Post(0)