jdbc桥接

import java.util.*;
import java.io.*;
import java.sql.*;
public class jdbc1{


String use;
String pwd;
String url;
String driver;
PreparedStatement ps;
Statement st;
String sql;
Connection cn;
ResultSet rs;
public static void main(String[] args) {
// TODO Auto-generated method stub
jdbc1 j1=new jdbc1();
}
public jdbc1(){
use="sa";
pwd="sql";
sql="select * from mybase";
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";//com.microsoft.sqlserver.jdbc.SQLServerDriver
url="jdbc:microsoft:sqlserver://127.0.0.1:1433;"+"databaseName=temp";
try {
Class.forName(driver);
cn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;"+"databaseName=temp","sa","sql");
ps=cn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next())
{
String info=rs.getString(1);
System.out.print(info);
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}finally{

try {
rs.close();
ps.close();
cn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

//注册驱动
}


}
阅读更多
上一篇zip压缩文件2
下一篇thread
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭