library management system using jdbc source code
// 使用JDBC直接建立数据库连接
import java.sql.*;
public class Jdbc{
public static void main(String[] args){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url ="jdbc:microsoft
qlserver://127.0.0.1:1433";
Connection con=DriverManager.getConnection(url,"admin","xyz" );
con.setCatalog("bookTest");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select * from bookInfo");
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getString(2)
+" "+rs.getFloat(3)+" "+rs.getString(4));
}
rs.close();
stmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
}