连接mssql2000

	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();
		}

	}

你可能感兴趣的:(jdbc,Microsoft)