我试图在Unix上通过Java连接到SQL Server。
但是当我在HP UX Itanium Unix服务器上试用它时,
我可以连接sql server 但我无法获取任何行。
我该怎么办?我真的堆在我不知道的地方。
这是我的Java代码;
package javaSQL;
import java.lang.*;
import java.sql.*;
import javax.management.Query;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class c = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Driver drv = (Driver) c.newInstance();
Connection conn = drv.connect("jdbc:sqlserver://127.0.0.1:2301;databaseName=Shelter; user=new_user; password=12345678",null);
System.out.println("Connection is established.." + conn);
System.out.println("Query is executing...");
PreparedStatement preparedStatement = conn.prepareStatement("select * from AlarmList");
ResultSet rs = preparedStatement.executeQuery();
System.out.println("AREA_NAME|MIN|PERSID|TEL|SMS|STARTDATE|ACTIVATED");
while (rs.next()) {
System.out.print(rs.getString("areaName") + "|");
System.out.print(rs.getString("duration") + "|");
System.out.print(rs.getString("senderName") + "|");
}
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}
真的是Thanx, 问候 格克