JDBC Connection
JDBC Connection
If you have set a password, then use this command and then enter your password.
mysql -u root -p
package databasejava;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
}catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
}
Here, for getConnection method you must you your database credentials correctly. In my case database
is javadb, user is default root, port is 3306 and password is empty. Exceptions are created to catch the
unexpected behaviors. Ex: If the Driver is not found or Connection is not created....
Now you have established a new database connection successfully! So, this is not enough! We have to
do something using this database connection. Therefore my next articles will be based on JAVA CRUD
operations. Till then,
Good Bye!!!