public 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();
} } }
public 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();
} } }
© 版权声明
文章版权归作者所有,未经允许请勿转载。