Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hospital.emr;
- import java.sql.*; // need to import the java.sql package to use JDBC
- //import java.util.ArrayList; // needed for arraylist
- public class JdbcConnection
- {
- Connection conn;
- Statement stmt;
- ResultSet rset;
- //ArrayList<ResultSet> rset = new ArrayList<ResultSet>(); // create an arraylist of result sets
- // constructors
- public JdbcConnection()
- throws SQLException
- {
- // Load the Oracle JDBC driver
- DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
- // Connect to the database
- Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.128:1521:xe", "hr","password");
- // Create a Statement
- Statement stmt = conn.createStatement();
- System.out.println("Database connection successful.");
- }
- // not sure if this should go in LoginActivity.java or here??
- public void CheckLogin(String username, String password)
- {
- try {
- rset = stmt.executeQuery("select USER_TYPE from USERS where USER_NAME = '" + username + "'" + "and USER_PASSWORD = '" + password + "'");
- while (rset.next())
- {
- System.out.println("Login successful!");
- System.out.println("User Type = " + rset.getString(1));
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment