0

How to connect mysql with java netbeans?

I've searched alot but still unable to connect the database? Please help!

7th Jul 2019, 12:45 PM
Maleeha Khalid
Maleeha Khalid  - avatar
3 odpowiedzi
+ 1
Iterator you can connect Java to database by making an db file in which the connection code is written like this way import java.sql.Connection; import java.sql.DriverManager; public class DB { public static Connection getConnection(){ Connection con=null; try{ Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:8080/demo","",""); }catch(Exception e){System.out.println(e);} return con; } }
7th Jul 2019, 12:53 PM
MsJ
MsJ - avatar
+ 1
Iterator the code which I have posted is of connection file to any database you have to first write this code and include this file in all your other project file and use the database for any CRUD operation
7th Jul 2019, 1:03 PM
MsJ
MsJ - avatar
0
first they ask to add connection file of sql server (which I'm unable to find) Mohit the coder (M.S.D)
7th Jul 2019, 1:01 PM
Maleeha Khalid
Maleeha Khalid  - avatar