
#Mysql jdbc password
Oracle database connection string format is other important details are database username and password details to be used for connecting to the database server. MySQL database connection String format is jdbc:mysql://:/.
#Mysql jdbc driver
Every database driver has it’s own way to configure the database URL but all of them have host, port and Schema details in the connection URL. The second important part is the database connection URL string. You will find these driver classes in their respective driver jar files. The first thing we should know is the Driver class to use. #Oracle DB configurations are the most important details when using JDBC API. #DB_URL=jdbc:mysql://localhost:3306/UserDB All we would need is to change the property details. This will help us in switching from Oracle to MySQL database easily and vice versa. We will read the database configuration details from the property files. JDBC Database Configuration Property File If you have maven based application, you can use below dependencies too.

Usually these jars shipped with the installer, so you can find them in the installation package.
#Mysql jdbc drivers
Make sure you are using the correct version of the java drivers according to your database server installation version.

JDBC Example – Database DriversĪs you can see in the project image, I have both MySQL (mysql-connector-java-5.0.5.jar) and Oracle (ojdbc6-11.2.0.1.0.jar) type-4 drivers in the lib directory and added to the project build path. However both the databases confirms to SQL language, so insert queries are same for both the database tables. Notice that datatypes in Oracle and MySQL databases are different, that’s why I have provided two different SQL DDL queries to create Users table. INSERT INTO Users (id, name, email, country, password) Run below SQL scripts to create the table and insert some dummy values in the table. For showing how we can achieve loose-coupling in connecting to databases using JDBC API, I will use Oracle and MySQL database systems. We will write program to connect to database server and run a simple jdbc query and process the results.

Installing the database servers is not in the scope of this tutorial, so I will assume that you have database servers installed.
#Mysql jdbc code
Let’s create a simple JDBC Example Project and see how JDBC API helps us in writing loosely-coupled code for database connectivity.īefore starting with the jdbc example, we need to do some prep work to have some data in the database servers to query. However for this solution, we should use database specific drivers, for example OJDBC jars provided by Oracle for Oracle DB and MySQL Connector/J for MySQL databases. This solution doesn’t require any extra APIs at the client side and suitable for database connectivity over the network.

We should have database client API installed at the machine from which we want to make database connection.
