在java中怎么连接数据库sqlserver 2005
1个回答
展开全部
static void testQuerySQL2005() throws Throwable {
String driver="net.sourceforge.jtds.jdbc.Driver";// 驱动jtds
Driver driver = (Driver) Class.forName(driver).newInstance();
DriverManager.registerDriver(driver);
String jdbcUrl = "jdbc:jtds:sqlserver://127.0.0.1:1433/master;charset=gbk;instance=SQLEXPRESS";// instance为数据库的实例名称,用于有多个数据库实例的情况
Connection conn = DriverManager.getConnection(jdbcUrl, "sa", "passwrod");
ResultSet rs = conn.createStatement().executeQuery("select * from spt_values");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询