+ 1

I am new to coding and would like some help on how to connect, and display data from a MySQL database

java connection string to MySQL database

12th Nov 2016, 6:30 AM
Bugingo K. Daniel
Bugingo K. Daniel - avatar
1 ответ
+ 1
i just got this i hope it works out... import java.sql.Connection; import java.sql.DriverManager; public class Main { public static void main(String[] argv) throws Exception { String driver = "com.mysql.jdbc.Driver"; String connection = "jdbc:mysql://localhost:3306/YourDBName"; String user = "root"; String password = "root"; Class.forName(driver); Connection con = DriverManager.getConnection(connection, user, password); if (!con.isClosed()) { con.close(); } } }
12th Nov 2016, 7:03 AM
Bugingo K. Daniel
Bugingo K. Daniel - avatar