package org.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SyBaseJDBC {
public static void main(String[] args) {
ResultSet rs = null;
Statement stmt = null;
Connection conn = null;
String driver = "com.sybase.jdbc3.jdbc.SybDriver";
String url = "jdbc:sybase:Tds:127.0.0.1:5000/eomsdbbk?user=develop&password=develop&useUnicode=true?CHARSET=cp936";
// 加载驱动
try {
Class.forName(driver);
conn = DriverManager.getConnection(url);
stmt = (Statement) conn.createStatement();
rs = stmt.executeQuery("select * from tbAddrListGrp ");
while (rs.next()) {
System.out.println(rs.getInt("iAddrListGrpId"));
System.out.println(rs.getInt("iPid"));
System.out.println(rs.getString("sName"));
System.out.println(rs.getString("sRemark"));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
sybase的JDBC连接