Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sqlmain;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class SqlTest {
- /* URL: jdbc:mysql://hostname:port/database */
- private static final String url = "jdbc:mysql://localhost:3306/dummy";
- private static final String user = "root";
- private static final String pass = "admin";
- public static void main(String[] args) {
- System.out.println("Connecting to DB...");
- /* Connection test to DB */
- try (Connection connection = DriverManager.getConnection(url, user, pass)) {
- System.out.println("Connected!");
- } catch (SQLException e) {
- System.err.println(String.format("Something went wrong: %s", e.getMessage()));
- }
- }
- }
Add Comment
Please, Sign In to add comment