sqlserver2008连接代码(Java)
程序员文章站
2022-06-24 20:17:16
sqlserver2008连接代码(Java)。
ublic class SqlServer { public static void main(String[] args) {...
sqlserver2008连接代码(Java)。
ublic class SqlServer { public static void main(String[] args) { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=mydb;", "user", "pass"); Statement st = conn.createStatement(); ResultSet rs=st.executeQuery("select * from aa10"); while (rs.next()) { System.out.println(rs.getString(1)); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }