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. 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. 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) Installation Instructions for the UNIX version of the JDBC Driver 1. We recommend that you unpack this zip file inProgramFiles with the default directory: 'Microsoft JDBC Driver x.x for SQL Server'. Work is the project name, therefore work package is imported here import java.sql.* Enter an installation directory when prompted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |