jdbc tool class for connecting to Oracle database
The oracle rack package is under the oracle installation address
D:\Oracle\product\11.2.0\dbhome_1\jdbc\lib\。
It's the shelf package that connects to the database
jdbc tool class for connecting to Oracle database
package ; import ; import ; import ; /** * Connect to database tool class */ public class DBHelper { /** * Get the database connection object * * @return */ public static Connection getConn() { Connection conn = null; //Define the database driver String driver = ""; //Define database connection String url = "jdbc:oracle:thin:@localhost:1521:orcl"; //Define database account String user = "super"; //Define the database password String password = "super"; try { //Load the database driver (driver); //Get the database connection conn = (url, user, password); } catch (Exception e) { (); } return conn; } /** * Free up resources * * @param conn */ public static void release(Connection conn) { try { if (conn != null) (); } catch (SQLException e) { (); } } }
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.