Driver == jdbc:oracle:thin:@192.168.10.105:1521== LF
ImportJava.io.InputStream;Importjava.sql.Connection;ImportJava.sql.DriverManager;Importjava.util.Properties; Public classJdbctools {//Properties File name Private StaticString defaultname = "Jdbc.properties"; /*** Get connection *@returnConnection *@throwsException*/ Public StaticConnection getconnection ()throwsexception{Connection Connection=getconnection (DefaultName); returnconnection; } /*** Get connection by properties file name *@paramFileName Properties File name *@returnConnection *@throwsException*/ Public StaticConnection getconnection (String fileName)throwsexception{//IO Stream read jdbc.properties fileInputStream in = Jdbctools.class. getClassLoader (). getResourceAsStream (FileName); //reading ParametersProperties p =NewProperties (); P.load (in); String URL= P.getproperty ("url"); String User= P.getproperty ("User"); String Password= P.getproperty ("Password"); String Driver=p.getproperty ("Driver"); Class.forName (driver); Connection Connection=drivermanager.getconnection (URL, user, password); if(in!=NULL) {in.close (); } returnconnection; } }
Java JDBC Connect Oracle III (Encapsulation tool Class)