The following describes how to connect JAVA to the Oracle database by using the Commons DbUtils component to connect to the database. You can use this JAVA method to connect to the Oracle database for your reference.
It encapsulates some classes in JDBC twice, and maps JAVA objects to databases like hibernateORMapping. First, introduce the oracle Driver Class file and the JAR file of the Commons DbUtils component to the project.
- String sql = "insert into users(username,password) values(?,?)";
-
- String username = request.getParameter("username");
-
- String param[]={StringUtil.filterHtml(username),StringUtil.filterHtml(request.getParameter("password"))
- };
-
- try {
-
- Context initContext = new InitialContext();
- DataSource ds = (DataSource) initContext.lookup("java:/comp/env/jdbc/oracleds");
- QueryRunner qr = new QueryRunner(ds);
- result = qr.update(sql, param);
-
- } catch (NamingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
C # connect to the Oracle database to query data
Test connection to the Oracle Database Server
Connect Perl to the Oracle database
Connect to the Oracle database through the OCI8 Interface
Three methods for automatic Oracle Database Backup