JDBCè¿æ¥Access第ä¸ç§æ¹æ³:
ä½ ç¨ä¸é¢ç代ç è¯è¯ ï¼å¼ºç建议ä¹æ¯onlyå¯ä»¥å»ºè®®çæ¹æ³ï¼
con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb","dba","sql");
åé¢ç代ç ä¸æ ·ãè¿æ ·ä½ å°±å¯ä»¥è®¿é®accessæ°æ®åºäºã
JDBCè¿æ¥Access第äºç§æ¹æ³:
ç¨sunçjdbcodbcæ¡¥ï¼æ°æ®æºï¼ä¸ªäººä¸»é¡µä¸éç¨ï¼
JDBCè¿æ¥Access第ä¸ç§æ¹æ³:
ç¨AccessçJDBC驱å¨ç¨åºï¼å°
http://industry.java.sun.com/products/jdbc/driversè¿ä¸ªç½ç«ä¸æ¥æ¾å¹¶ä¸å¨Accessçjdbc驱å¨ç¨åºã ï¼è¿ä¸ªæ²¡æè¯è¿ï¼åä½æå
´è¶£å¯ä»¥è¯è¯çï¼
对äºè®¾ç½®ä¸Windowsä¸çJSPæå¡å¨ï¼ä¸ç³»ç»è¾å°æ¶ï¼ä½¿ç¨Accessæ¯ä¸ä¸ªæ¯è¾å¥½çéæ©ï¼ä½æ¯è¦ä½¿ç¨Accessæ°æ®åºä¸è¬è¦éè¿æ°æ®æºãè¿éæä¾ä¸ç§ä¸ç¨ä½¿ç¨æ°æ®æºç¨Javaç´æ¥è¿æ¥æ°æ®æºçæ¹æ³ãä¾åç¨åºå¦ä¸ï¼
import java.sql.*; public class Access { public static void main(String args[]) { try { String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=books.mdb"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(strurl) ; Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from books"); if(rs.next()) { System.out.println(rs.getString("ç®ä»")); } }catch(Exception e) { System.out.println(e); } } }
å¯ä»¥çå°åªè¦å¨driveråé¢å ä¸ODBC驱å¨å³å¯ä¸ç¨è®¾ç½®æ°æ®æºï¼è¿ç§æ¹æ³å¯¹å
¶ä»å°åæ°æ®åºï¼å¦forproï¼åºè¯¥ä¹éç¨ã