Generation

generate functionWed, 25 Jan 2023

Write a program to connect to mysql database named Person

public class CreateConnection extends JFrame { private String dbHost = "localhost"; private String dbPort = "3306"; private String dbUser = "root"; private String dbPass = "root"; private String dbName = "Person"; public void connect() { try { Class.forName("com.mysql.jdbc.Driver"); String CONNECTION_URL = "jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName; Connection conn = DriverManager.getConnection(CONNECTION_URL, dbUser, dbPass); } catch (Exception ex) { System.err.println("Got an exception! "); System.err.println(ex.getMessage()); } } }

Questions about programming?Chat with your personal AI assistant