首先设置odbc数据源:在系统dsn中加入数据源
在jsp中书写如下:
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println( "SQLException:"+e.getMessage());
}
try
{
Connection con=DriverManager.getConnection( "jdbc:odbc:你的数据源中的名字);
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("select * from 表名");
在jsp中书写如下:
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println( "SQLException:"+e.getMessage());
}
try
{
Connection con=DriverManager.getConnection( "jdbc:odbc:你的数据源中的名字);
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("select * from 表名");
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货