The JDBC connection data is a key point of javaweb development, and today we summarize and deepen our memory.
The JDBC Connection database is divided into three steps:
1: Load Driver
Need to download the respective drive jar package, you can go to the Internet search.
Template: load driver: Class.forName (Driverclass);
Different database connections are not the same way, I would like to summarize:
MySQL: com.mysql.jdbc.Driver
Oracle: Oracle.jdbc.OracleDriver
SQL Server: com.microsoft.sqlserver.jdbc.SQLServerDriver
2: Get a data connection
mysql: Connection con =drivermanager.getconnection ("jdbc:mysql://127.0.0.1:3306/ database name " ," Database user "," Database Password ");
SQL Server: Connection con = drivermanager.getconnection ("Jdbc:sqlserver://127.0.0.1:1433;databasename= Database name "," Database User "," Database Password ");
Oracle: Connection con = drivermanager.getconnection ("jdbc:oracle:thin:@127.0.0.1:1521: Database Name", "Database User", " Database Password ");
3: Create a statement object
Conn.creatstatement ();
Then you can do the SQL operation, remember to use the end to close!
Mysql,oracle,sqlserver using JDBC to connect to a database summary