Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Database;
- import java.sql.DriverManager;
- public class Connection {
- public java.sql.Connection connection;
- public java.sql.Connection getConnection() {
- String userName = "root";
- String password = "";
- try {
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println("Connecting to Database....");
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/stockmanagement?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT", "root","");
- } catch (Exception ex) {
- System.out.println(ex.toString());
- System.out.println("Couldn't Connect to the database.\nEither the database isn't online or it doesn't exist.");
- System.exit(1);
- }
- return connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement