用javascript编写连接access数据库代码
并生成相关字符串。
var con = new ActiveXObject("ADODB.Connection");
con.Provider = "
}
rsjavascript是可以连接本地数据库的,以下是示例代码:
<.write (cnt);/以当前页面文件为基础,找到文件所在的绝对路径.open (sqlSelCnt.0";
con;
/.4://javascript".href.substring(0, location.href。
path = path.substring(8);
var updateCnt = 0;
//这8个字符;content");
document;ADODB.html".indexOf(".eof) {
var cnt = rs.Fields("javascript"。
var filePath = location,con);
while (!rs.mdb";"index;
rs.moveNext;去掉字符串中最前面的"
rs = null.ConnectionString = "Data Source=" + path;
con;/建立连接.OLEDB;));
var path = filePath + "MyData;生成查询和更新用的sql语句。
var sqlSelCnt = "SELECT * FROM [user]";
//.Jet;Microsoft;files.close(); language="!--
function getCountFromDB() {
/.open;
var rs = new ActiveXObject(".Recordset");
rs
JAVA连接ACCESS数据库
曾经看到过一种最简单的连接access数据库的方法,不需要配置数据源,也不需要安装驱动======================================================================
import java.sql.*;
public class ToAccess {
public static void main(String args[]) {
try {
String url = \"jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\\\bookshop.mdb\";
Class.forName(\"sun.jdbc.odbc.JdbcOdbcDriver\");
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(\"select * from books\");
while (rs.next()) {
System.out.println(\"The book\'s name is:\" + rs.getString(\"book\"));
System.out.println(\"The author is: \" + rs.getString(\"author\"));
}
rs.close();
stmt.close();
conn.close();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
java怎么连接access数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
publicclassSelect {
publicstaticvoidmain(String[] args) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// String url = "jdbc:odbc:wombat";
// string url=“jdbc:odbc:Driver={MicroSoft Access Driver
// (*.mdb)};DBQ=“+application.getRealPath(“/Data/ReportDemo.mdb“);
String url = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:\\Test.mdb";
Connection conn = DriverManager.getConnection(url, "", "");
Statement stmt = conn.createStatement();
}catch(SQLException e){
System.out.println("连接数据库出错。");
}
}