Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class hospital{
- public static void main(String[] args){
- Connection con = null;
- PreparedStatement st= null;
- ResultSet rs = null;
- String url = "jdbc:mysql://localhost:3306/hospital";
- String user = "ripefruit";
- String password = "secretpassword";
- System.out.println("Attempting to connect...");
- try{
- con = DriverManager.getConnection(url, user, password);
- System.out.println("Connected to database!");
- st = con.prepareStatement("select * from Patient");
- rs = st.executeQuery();
- } catch (SQLException e){
- System.out.println("Cannot connect to the database!");
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement