Frequently Asked Question

FAQ / Dedicated JVM


How to set DB Configuration in Java Property file?

For configuration purposes, using properties file is a good way of reusing. In this way, when the code is packaged to a jar file, users can just put the different configurations in the config.properties file, instead of recompile the application.

MySQL (mysql-connector-java-5.0.5.jar) drivers should be put into lib directory and added to the project build path. Make sure you are using the correct version of the java drivers according to your database server installation version.

Your application will read the database configuration details from the property files, so that it can easily switch from Oracle to MySQL database and vice versa, just by changing the property details.


<b>#mysql DB properties
</b>#DB_DRIVER_CLASS=com.mysql.jdbc.Driver#DB_URL=jdbc:mysql://localhost:3306/UserDB#DB_USERNAME=pankaj#DB_PASSWORD=pankaj123
<b>#Oracle DB Properties
</b>DB_DRIVER_CLASS=oracle.jdbc.driver.OracleDriverDB_URL=jdbc:oracle:thin:@localhost:1571:MyDBSIDDB_USERNAME=scottDB_PASSWORD=tiger

Database configurations are the most important details when using JDBC API. The first thing we should know is the Driver class to use. For Oracle database, driver class is oracle.jdbc.driver.OracleDriver and for MySQL database, driver class is com.mysql.jdbc.Driver. You will find these driver classes in their respective driver jar files and both of these implement java.sql.Driver interface. ( For Mysql connection string format is jdbc:mysql://<$HOST>;<$PORT>/<$SCHEMA> and for Oracle database connection string format is jdbc:oracle:@<$HOST>;<$PORT>:<$SID>.)
<host>
<port>
<schema>
<host>
<port>
<sid>
</sid>
</port>
</host>
</schema>
</port>
</host>

How this faq is helpful:

Not at all
helpful
Not much
helpful
Some what
helpful
Very
helpful
Extremely
helpful

What could be better? (Optional)
X
  Not related to my issue
  Too complicated explanations
  Too much information
  Incorrect information
  Unclear information
  Incomplete information
  Too old information
Do you have any other feedback about this faq ?
1000