概述
package jsp;
import java.sql.*; // JDBC package
public class sql_data {
String url = "jdbc:inetdae:192.168.2.70?sql7=true"; // use your hostname and port number
String login = "sa"; // use your login here
String password =""; // use your password here
public Connection connection = null;
public Statement st = null;
public ResultSet rs = null;
public sql_data(){
try {
Class.forName("com.inet.tds.TdsDriver").newInstance();
DriverManager.setLoginTimeout(10);
} catch(Exception e) {
e.printStackTrace();
}
}
public void sqlclose() {
try {
st.close();
connection.close();
}
catch(SQLException ex) {
System.err.println("sqlclose: " + ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
try {
connection = DriverManager.getConnection(url,login,password);
connection.setCatalog( "register");
st = connection.createStatement();
rs = st.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}
最后
以上就是外向仙人掌为你收集整理的以IP与Port建立与SQLSERVER的连接的全部内容,希望文章能够帮你解决以IP与Port建立与SQLSERVER的连接所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复