package com.ytu;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Test {
public static void main(String[] args) {
String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student";
String user = "sa";
String password = "123456";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from info");
while(rs.next()) {
System.out.println(rs.getString(3));
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("Error Happened");
}
}
}