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