但是我在命令行里进行测试时出现以下问题.请问这该如何解决?
另外,我在Deamweaver中用JSP通过JDBC和SQL2000连接时出现以下问题,
[Microsoft][SQLServer 2000 Driver for JDBC]Unsupported VM encoding MS936
这个又如何解决呢?
这是代码:
// Java Document
import java.sql.*;
public class DBTest {
Connection con;
Statement sta;
String driver;
String url;
String user;
String pwd;
ResultSet rs=null;
public DBTest(){
driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName =pubs";
user= "sa";
pwd= "1";
init();
}
public void init()
{
try{
Class.forName(driver);
System.out.println("driver is ok");
con = DriverManager.getConnection(url,user,pwd);
System.out.println(con);
System.out.println("conection is ok");
sta = con.createStatement();
System.out.println(sta);
System.out.println("createStatement is ok");
rs=sta.executeQuery("select * from admintable");
while(rs.next())
System.out.println(rs.getInt("username"));
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new DBTest();
}
}