jdbc访问access
lor=black>
package test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
public class Runtest {
public static void main(String args[]) throws Exception {
long cateId;
String cateName;
String newsTitle;
int browse_count;
String content;
String flashUrl;
String articleAbstract;
String picUrl;
PreparedStatement ps = null;
/* 开始从数据源中读出数据 */
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=F:/SqlIn.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");// 用JDBC-ODBC方式
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet rest = stmt
.executeQuery("select * from t1,t2 c where c.id = clng(i.classid)");
//List<Newstest> list = new ArrayList<Newstest>();
while (rest.next()) {
String flashurl = rest.getString("x");
System.out.println("flashurl="+flashurl+"<br/>");
}
rest.close();
stmt.close();
conn.close();
/* 结束从数据源中读出数据 */
}
}
System.out.println("flashurl="+flashurl+"<br/>");
}
rest.close();
stmt.close();
conn.close();
/* 结束从数据源中读出数据 */
}
}
lunzi
2008-01-18 16:48:21
评论:0
阅读:378
引用:0
