Guest User

Untitled

a guest
Jul 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package mysqldatabaseaccess;
  2.  
  3. import java.sql.*;
  4. import java.io.*;
  5.  
  6. /**
  7.  *
  8.  * @author Administrator
  9.  */
  10. public class MySQLDatabaseAccess {
  11.  
  12.     public static void openConnection() {
  13.        
  14.         // Prompt for password to access MySQL                
  15.         InputStreamReader istream = new InputStreamReader(System.in);
  16.         BufferedReader buffRead = new BufferedReader(istream);
  17.        
  18.         try {
  19.             System.out.println("Please enter the password: ");
  20.             String prompt = buffRead.readLine();
  21.         }
  22.         catch (IOException err) {
  23.             System.out.println("An error occured reading buffer.");
  24.         }
  25.        
  26.         Connection conn = null;
  27.         String url = "jdbc:mysql://localhost:3306/";
  28.         String dbName = "jdbc";
  29.         String drive = "com.mysql.jdbc.Driver";
  30.         String userName = "root";
  31.         String password = prompt;                              // <-- this is where i get red zig-zags
Add Comment
Please, Sign In to add comment