关于如何用JBuilder操作SQLserver数据库?要导入哪些包?如何导入?最好给个例子.的问题
把sqlserver jdbc驱动加到classpath中,三个jar包。
import java。sql。*;
public class DbTest
{
Connection con;
Statement sta;
ResultSet rs;
String driver;
String url;
String user;
String pwd;
public DbTest()
{
driver = “sun。
jdbc。odbc。JdbcOdbcDriver”;
url = “jdbc:odbc:store_manager”;
user = “share”;
pwd = “share”;
init();
}
public void init()
{
try{
rName(driver);
intln(“driver is ok”);
con = tConnection(url,user,pwd);
intln(“conection is ok”);
sta = eateStatement();
rs = sta。
executeQuery(“select * from room”);
while( xt())
intln( tInt(“roomNum”));
}
catch(Exception e)
{
intStackTrace();
}
}
public static void main(String[] args)
{
new DbTest();
}
}。