package com.book.util;
import java.sql.*;
public class JdbcDemo{
public static void main(String args[]){
int pty;
float cost;
String book;
String bookid;
String query = "SELECT Name, Description,Qty,Cost FROM Stock";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://127.0.0.1","sa","sa");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM book where bookid = 001");
while (rs.next()){
System.out.println(rs.getString("bookid"));
}
con.close();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
}
}