欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

连接mssql2000 博客分类: mssql MicrosoftJDBC 

程序员文章站 2024-03-16 11:38:04
...
	private static void connect2000() {

		try {
			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
			Connection conn = DriverManager
					.getConnection(
							"jdbc:microsoft:sqlserver://192.168.6.45:1433;DatabaseName=pubs",
							"sa", "sa");

			PreparedStatement pstm = conn
					.prepareStatement("select * from jobs");
			ResultSet rs = pstm.executeQuery();
			while (rs.next()) {
				System.out.println("job_id=" + rs.getInt("job_id"));
			}
			if (rs != null) {
				rs.close();
			}
			if (pstm != null) {
				pstm.close();
			}
			if (conn != null) {
				conn.close();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}

	}
相关标签: Microsoft JDBC