sourcejavacode
Wednesday, January 29, 2014
Getting Connection Using Properties File in JDBC
1. Create JDBC Connection Using Properties file.
Programs:
a) JDBC.properties
b) Test.java
a)JDBC.properties
driverClass=sun.jdbc.odbc.JdbcOdbcDriver url=jdbc:odbc:test user=system password=tiger
b)Test.java
import java.sql.*; import java.io.*; import java.util.*; class Test { public static void main(String ar[]) throws Exception { Properties p=new Properties(); p.load(new FileInputStream("JDBC.Properties")); Class.forName(p.getProperty("driverClass")); Connection con = DriverManager.getConnection( p.getProperty("url"),p); if(con!=null) System.out.println("Connected"); con.close(); } }
No comments :
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments ( Atom )
No comments :
Post a Comment