当前位置: 移动技术网 > IT编程>开发语言>Java > java当中JDBC当中请给出一个sql server的dataSource的helloworld例子

java当中JDBC当中请给出一个sql server的dataSource的helloworld例子

2019年10月05日  | 移动技术网IT编程  | 我要评论

 [学习笔记]

4. sql server的datasource的helloworld:

import java.sql.*;
import javax.sql.*;
import net.sourceforge.jtds.jdbcx.*;

public class simpledatasource{
public static void main(string[] args){
try{
jtdsdatasource ds = new jtdsdatasource();
ds.setservername("localhost");
ds.setdatabasename("pubs");
ds.setuser("sa");
ds.setpassword("");

connection con = ds.getconnection();
statement s = con.createstatement();
resultset rs = s.executequery("select count(*) from authors");
if(rs.next())
system.out.println("there are " + rs.getint(1) + " records in authors table.");
}catch(exception e){

}
}
}

文章转载自原文:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网