//读数据库
private void readDB()
{
//注册数据库驱动程序
try{
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
}
catch(Exception e)
{System.err.println("注册数据库驱动程序错误:" + e);}
//从数据库读OLE或附件
try{
Connection con = DriverManager.getConnection(Url,JdbcUser,JdbcPwd);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM file_texts");
java.math.BigDecimal DocNo; InputStream inole;
while(rs.next()){
try{
DocNo = rs.getBigDecimal("NO",0);
inole = rs.getBinaryStream("FILE_TEXT");
saveFile(DocNo.toString(),inole);
System.out.println("存储过度文件:"+DocNo.toString());
}
catch(Exception e)
{System.err.println("存储过度文件错误:" + e);}
}
st.close();
con.close();
}
catch(Exception e)
{System.err.println("数据库查询错误:" + e);}
}
private void readDB()
{
//注册数据库驱动程序
try{
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
}
catch(Exception e)
{System.err.println("注册数据库驱动程序错误:" + e);}
//从数据库读OLE或附件
try{
Connection con = DriverManager.getConnection(Url,JdbcUser,JdbcPwd);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM file_texts");
java.math.BigDecimal DocNo; InputStream inole;
while(rs.next()){
try{
DocNo = rs.getBigDecimal("NO",0);
inole = rs.getBinaryStream("FILE_TEXT");
saveFile(DocNo.toString(),inole);
System.out.println("存储过度文件:"+DocNo.toString());
}
catch(Exception e)
{System.err.println("存储过度文件错误:" + e);}
}
st.close();
con.close();
}
catch(Exception e)
{System.err.println("数据库查询错误:" + e);}
}
public class text{
public static void main(String arg[] )
{
String url="jdbc:odbc:text";
String query="SELECT * FROM text";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection(url,"","");
Statement statement=connection.createStatement();
ResultSet resultset=statement.executeQuery(query);
while (resultset.next())
{
System.out.println(resultset.getInt(1)+"\t"+resultset.getInt(2));
}
statement.close();
}
catch (ClassNotFoundException cnfex){
System.err.println("failed to load ");
cnfex.printStackTrace();
System.exit(1);
}
catch (SQLException sqlex)
{System.err.println("unable to connect");
sqlex.printStackTrace();
}
}
}
jdbcodbc桥驱动不用下,jdk里面带的有,直接用就是了