Database Connectivity with java to any database by single configuration file -


how can configure database java through configuration file. means can switch any database java through configuration file. code configure mysql database

<?xml version="1.0" encoding="utf-8"?> <config>     <jdbc>         <url>jdbc:mysql://localhost:3306/javabase</url>         <driver>com.mysql.jdbc.driver</driver>         <username>java</username>         <password>d$7hf_r!9y</password> </jdbc> </config> 

like want configure database like(oracle, sqlserver) java single configuration file. can possible ? , how call in java application

is possible? within bounds, yes. bounds must restrict using sql of databases want use can understand. can problem, because different databases use non-standard syntax, non-standard extensions, support different sets of data types have different languages stored procedures, triggers , on.

the problem more databases support smaller set of sql have in common. point need generate / use different sql depending on database. before then, need use database abstraction layer in code ... or orm hibernate.


the config easy bit. load driver class , call drivermanager.getconnection url, username , password in config file; see https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -