从ms访问中提取数据 [英] pulling data from ms access
本文介绍了从ms访问中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从ms访问中提取特定数据(应该定义行,列)..但是用我的代码我已经提取了所有内容..有人可以告诉我如何从ms访问中提取特定数据吗?
i need to pull specific data from ms access (row,column should be defined).. but with my code i have pulled everything.. can somebody show me how to pull specific data from ms access??
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver " +
"(*.mdb, *.accdb)};DBQ=C:\\Database\\2010 salary adjustment.accdb";
Connection con = DriverManager.getConnection(url);
System.out.println("Connected!");
Statement stmt = null;
ResultSet rs = null;
// SQL query command
String SQL = "SELECT * FROM Table1";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
jTextArea1.setText(rs.getString("gender") + ":"
+ rs.getString("NAME") + ":"
+ rs. getString("PosTit"));
}
con.close();
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+
cE.toString());
}
推荐答案
好吧,您正在要求一切
SELECT * FROM Table1
您需要指定要获取的内容
well you are asking for everything
SELECT * FROM Table1
You need to specify what you want to get
SELECT * from Table1<br />
WHERE some criteria
请参见教程 [
see here for tutorial [^]
这篇关于从ms访问中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文