Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. package edu.uic.ids401.util;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.sql.ResultSet;
  6. import java.util.Scanner;
  7.  
  8. public class DBaseMain {
  9.  
  10.    
  11.     public static void main(String[] args) {
  12.        
  13.         String userName=null;
  14.         String password=null;
  15.         String dbmsServer=null;
  16.         String dbmsType=null;
  17.         String dbScheme=null;
  18.  
  19.        
  20.         Scanner keyboard=new Scanner(System.in);
  21.         System.out.println("What is your username?");
  22.         userName= keyboard.next();
  23.         System.out.println("What is your password?");
  24.         password= keyboard.next();
  25.         System.out.println("What is the dbmsServer name");
  26.         dbmsServer= keyboard.next();
  27.         System.out.println("What is your dbmsType");
  28.         dbmsType= keyboard.next();
  29.         System.out.println("What is your dbscheme");
  30.         dbScheme= keyboard.next();
  31.         System.out.print("Enter file name:");
  32.         String fileName=keyboard.next();
  33.         Scanner inputStream=null;
  34.        
  35.     String url = "jdbc:"+dbmsType+"://"+dbmsServer+":3306"+"/"+dbScheme;   
  36. DBase dbase= new DBase("com.mysql.jdbc.Driver",url,userName,password);
  37. ResultSet rs=null;
  38. rs = dbase.executeSQLdmlQuery(keyboard.nextLine());
  39.  
  40.  
  41. try
  42. {
  43.     inputStream=new Scanner(new File(fileName));
  44.  
  45. }
  46.  
  47. catch(FileNotFoundException e)
  48. {
  49.     System.out.println("Error opening the file"+ fileName);
  50.     System.exit(0);
  51. }
  52.  
  53. while(inputStream.hasNextLine())
  54. {
  55. String line=inputStream.nextLine();
  56. System.out.println(line);
  57. }
  58. inputStream.close();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement