Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.uic.ids401.util;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.Scanner;
- public class DBaseMain {
- public static void main(String[] args) {
- String userName=null;
- String password=null;
- String dbmsServer=null;
- String dbmsType=null;
- String dbScheme=null;
- Scanner keyboard=new Scanner(System.in);
- System.out.println("What is your username?");
- userName= keyboard.next();
- System.out.println("What is your password?");
- password= keyboard.next();
- System.out.println("What is the dbmsServer name");
- dbmsServer= keyboard.next();
- System.out.println("What is your dbmsType");
- dbmsType= keyboard.next();
- System.out.println("What is your dbscheme");
- dbScheme= keyboard.next();
- System.out.print("Enter file name:");
- String fileName=keyboard.next();
- Scanner inputStream=null;
- String url = "jdbc:"+dbmsType+"://"+dbmsServer+":3306"+"/"+dbScheme;
- DBase dbase= new DBase("com.mysql.jdbc.Driver",url,userName,password);
- ResultSet rs=null;
- System.out.print("What is your query?");
- String query=keyboard.next();
- rs = dbase.executeSQLdmlQuery(keyboard.nextLine());
- try {
- int numofCol= rs.getMetaData().getColumnCount();
- System.out.println(numofCol);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- try {
- rs.last();
- int rows = rs.getRow();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- try
- {
- inputStream=new Scanner(new File(fileName));
- }
- catch(FileNotFoundException e)
- {
- System.out.println("Error opening the file "+ fileName);
- System.exit(0);
- }
- while(inputStream.hasNextLine())
- {
- String line=inputStream.nextLine();
- System.out.println(line);
- }
- inputStream.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement