简体   繁体   中英

Java web application database connection

I'm trying to make simple java web application using Servlets & JSP, with a simple database connection . but I am reading about database connection and i found that there is some methods like Connection pool , JDBC Driver ... I don't know what is the best way , please help (I'm using eclipse)

A connection pool is a set of connections which are available for your application to use and eventually connect to the database. This set, which is of limited size (you can run out of connections) is made available to you by the database server.

On the other hand, the JDBC driver is a mechanism which Java provides so that Java applications can connect to databases.

I would recommend you take a look at this introductory tutorial so that you can get yourself better acquainted with the part of software development.

Oracle Thin Type 4 Driver is the best for database connection .Below is the code for connection.Hope u'll find it useful and btw Welcome to JAVA !!

Connection con=null;
    try{
        Class.forName("oracle.jdbc.OracleDriver");
        con=DriverManager.getConnection("jdbc:oracle:thin:@IP:PortNo:SID","USER","PWD");

    }
    catch(SQLException e){
        e.printStackTrace();
     }catch(ClassNotFoundException e){
        e.printStackTrace();
       }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM