Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- //jdbc:derby://localhost:1527/LMS
- class abc {
- public abc() throws SQLException{
- //ConnectionURL, username and password should be specified in getConnection()
- //ConnectionURL, username and password should be specified in getConnection()
- try {String url = "jdbc:derby://localhost:1527/LMS";
- Connection conn = DriverManager.getConnection(url,"zain","12345");
- System.out.println("Connected! ");
- String sql = "SELECT * FROM BOOK";`enter code here`
- Statement st = conn.createStatement();
- ResultSet rs=st.executeQuery(sql);
- String x;
- while(rs.next()){
- System.out.println(rs.getString("Password"));
- }
- }
- catch (SQLException ex) {
- System.out.println(ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement