JSP怎么连接ACCESS数据库? 1.建立数据库.2.配置数据源.3.写正确JSP代码. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有三种办法 第一种是用access的JDBC驱动程序,到http://industry.java.sun.com/products/jdbc/drivers这个网站上查找并下在access的jdbc驱动程序。 第二个办法是你用下面的代码试试 con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb","dba","sql"); 后面的代码一样。这样你就可以访问access数据库了。 第三个是用sun的jdbcodbc桥,这个大家用的多了,在此就不写了 //这个例子,是从SUN的站点上找来的。当时也找了好久啊。呵呵!// accepts sql statments thru command line import java.sql.*; import java.util.*; public class test { public static void main(String args[]){ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Properties prop = new Properties(); prop.put("user", ""); prop.put("password",""); prop.put("charSet","gb2312"); Connection conn=DriverManager.getConnection("jdbc:odbc:chinese",prop); //chinese 数据源Statement stmt=conn.createStatement(); stmt.execute(args[0]); } catch(ClassNotFoundException e) { // JOptionPane.showMessageDialog(null,"Unable To Load The Driver Class","Login Message", JOptionPane.ERROR_MESSAGE); } catch(SQLException e) { e.printStackTrace(); System.out.println(e.getErrorCode()); } } } 关于jsp分页显示求解 HTML文件点击"编辑"时候的打开方式是word,能改成Dreamweaver 8吗? 关于jsp(Struts + JDBC) struts+applet的项目,在网页中如何调试applet? 仿QQ面板 关于Filter,多重权限过滤问题 unix下连接连接oracle的问题 ,up有分 mule esb 怎么集合 webservice 用ireprot做好的报表引入到应用程序中碰到的问题,各位一起来看看! 我的序列号为什么一次运行会滚动多个? 大家是用什么工具来编译bean jsp中有查找子串的函数吗?
第一种是用access的JDBC驱动程序,到http://industry.java.sun.com/products/jdbc/drivers这个网站上查找并下在access的jdbc驱动程序。
第二个办法是你用下面的代码试试
con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb","dba","sql");
后面的代码一样。这样你就可以访问access数据库了。
第三个是用sun的jdbcodbc桥,这个大家用的多了,在此就不写了
// accepts sql statments thru command line
import java.sql.*;
import java.util.*;
public class test {
public static void main(String args[]){ try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Properties prop = new Properties();
prop.put("user", "");
prop.put("password","");
prop.put("charSet","gb2312"); Connection conn=DriverManager.getConnection("jdbc:odbc:chinese",prop); //chinese 数据源
Statement stmt=conn.createStatement();
stmt.execute(args[0]); } catch(ClassNotFoundException e)
{
// JOptionPane.showMessageDialog(null,"Unable To Load The Driver Class","Login Message", JOptionPane.ERROR_MESSAGE); }
catch(SQLException e)
{
e.printStackTrace();
System.out.println(e.getErrorCode());
} }
}