Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@
<version>2.8.0</version>
<scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.4.1</version>
<version>6.19.0</version>
</dependency>


<!-- https://mvnrepository.com/artifact/com.ibatis/ibatis2-common -->
<dependency>
<groupId>com.ibatis</groupId>
Expand All @@ -122,6 +124,11 @@
<artifactId>jasypt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>3.4.4</version>
</dependency>

</dependencies>
<name>HotelPropertiesManagementSystem</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,39 @@ public void runScriptFile() {

final InformationFrame dialog = new InformationFrame();
final String sqlFilePath = "src/com/coder/hms/connection/hotel_management_system.sql";
final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
final String DB_CONNECTION = "jdbc:mysql://localhost:3306/";
String DB_USER = JOptionPane.showInputDialog(this, "Enter your database user name :", "Coder HMS [Input]", JOptionPane.QUESTION_MESSAGE);
String DB_PASSWORD = JOptionPane.showInputDialog(this, "Enter your database password :", "Coder HMS [Input]", JOptionPane.QUESTION_MESSAGE);


try {

Class.forName(DB_DRIVER);
Connection connection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);

ScriptRunner runner = new ScriptRunner(connection, false, false);
Reader br = new BufferedReader(new FileReader(sqlFilePath));
ScriptRunner runner = new ScriptRunner(getConnection(), false, false);
Reader bufferedReader = new BufferedReader(new FileReader(sqlFilePath));

file = new File(System.getProperty("user.dir")+ File.separator + "Logging Store/SQL_Logs.txt");
PrintWriter writer = new PrintWriter(file);
runner.setLogWriter(writer);
runner.runScript(br);
runner.runScript(bufferedReader);
dialog.setMessage("Your database and tables created successfully.");

status = true;

} catch (SQLException | ClassNotFoundException | IOException ex) {
dialog.setMessage(ex.getMessage());
status = false;
}

dialog.setVisible(true);
}

public Connection getConnection() throws ClassNotFoundException, SQLException {

final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
final String DB_CONNECTION = "jdbc:mysql://localhost:3306/";
String DB_USER = JOptionPane.showInputDialog(this, "Enter your database user name :", "Coder HMS [Input]", JOptionPane.QUESTION_MESSAGE);
String DB_PASSWORD = JOptionPane.showInputDialog(this, "Enter your database password :", "Coder HMS [Input]", JOptionPane.QUESTION_MESSAGE);

Class.forName(DB_DRIVER);
Connection connection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
return connection;
}


public static File getLogFile() {
if(file.exists()) {
Expand Down