jdbc访问access

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();
/* 结束从数据源中读出数据 */

}

}

lor=black>

System.out.println(
"flashurl="+flashurl+"<br/>");
}

rest.close();
stmt.close();
conn.close();
/* 结束从数据源中读出数据 */

}

}

lunzi   2008-01-18 16:48:21 评论:1   阅读:1962   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog