![]() ![]() If you will now write the print statement then you will not get the console output but still, the application will be able to insert the data properly. Search the 'sqljdbc.jar' file in the directory where you unpacked the downloaded driver. Now go to the section 'Java Build Path - Libreries' y then click 'Add External JARs'. Secondary click in the root of the Eclipse project and go to 'Properties'. You must change the values as per your database requirements.Īlways remember that you must keep the JDBC connection code inside a try block as it can throw exceptions.Īfter writing the code, run the code as Java Application, after successful execution you’ll get the output on the console as “Insert Complete.” as shown in the below image. Adding the JDBC driver of MS SQL Server to Eclipse: Download the JDBC driver and uncompress it. We are inserting name, age, and class as Matt, 13, and 7 respectively. Statement myStmt = m圜onn.createStatement() String url = "jdbc:MySQL://localhost:3306/db" //db is the name of the databaseĬonnection m圜onn = DriverManager.getConnection(url,user,password) Work is the project name, therefore work package is imported here import java.sql.*
0 Comments
Leave a Reply. |