class mysqltest {public static void main (string [] ARGs) {connection conn = NULL; try {// load the MySQL Driver Class. forname ("com. mySQL. JDBC. driver "); // connect to MySQL on localhost and specify to use the test database. The username is root and the password is *** conn = drivermanager. getconnection ("JDBC: mysql: // localhost/test ", "Root", "***"); I
set to True, the time interval between two re-interconnects, units: seconds 2 1.1connectTimeout and database server establish Socke T timeout, in milliseconds, when connecting. 0 means never timeout, for JDK 1.4 and later 0 3.0.1socketTimeout Socke T operation (Read-write) timeout, in milliseconds. 0 means never timeout 0 3.0.1For the Chinese environment, the MySQL connection URL can usually be set to:jdbc
Common Methods for connecting to a database through JDBC are summarized as follows:
I. DB2
Class. forname ("com.ibm.db2.jdbc.net. db2driver ");
String url = "JDBC: DB2: // dburl: Port/dbname"
CN = drivermanager. getconnection (URL, username, password );
2. Microsoft sqlserver (Microsoft)
Class. forname ("co
Drivers and JDBC URLs for commonly used databases:
Oracle Database:
Driver Package Name: Ojdbc14.jar
Name of the driver class: Oracle.jdbc.driver.OracleDriver
JDBC url:jdbc:oracle:thin:@ Dbip:port:databasename
Description: Driver package name may be changed
The black font part of the JDBC
Oracle databases
4.1 load driver
The driver is located:
Oracle installation directory -- Ora92 -- lib -- ojdbc14.jar
Note: If the driver is not loaded, the exception is: java. lang. ClassNotFoundException: oracle. jdbc. driver. OracleDriver.
4.2 connection code
CODE:
server. 0 means never timeout, for JDK 1.4 and later
0
3.0.1
Sockettimeout
Socket operation (Read-write) timeout, in milliseconds. 0 means never time out
0
3.0.1
For the Chinese environment, the MySQL connection URL can usually be set to:jdbc:mysql://localhost:3306/test?user=rootpassword=useunicode=truecharacterencoding=gbk Autoreconnect=truefailoverreadonly=
Using JDBC to connect to the MySQL Tutorial database tutorial, the JDBC driver has been added to the project "build path" of Eclips tutorial E, which is supposed to be normal. Prompts "Unable to load driver" after running the project.
The final solution is to put the Mysql-connector-java-5.1.7-bin.jar into the "D:javajdk1.6.0_22jrelibext", and then compile and run the above program, it succeeds. As for why
The first thing to know about JDBC: the technology for sending SQL statements using Java code is JDBC technology. That is, JDBC is an interface for different databases (Oracle, MySQL, SQL Server ...). ) operation. Prerequisites for sending SQL statements using JDBC:Log on to the database server (connect to the database
Application Server 6.5, select the "database" Panel, select the "External JDBC Drivers" option, and click "Add... "Button, in the pop-up dialog box, add a JDBC Driver named" ora-type4.
Driver Classpath: Enter the physical path of the classes12.zip file.
Then, in "External JDBC DataSources", select "Add... ", Add a data source with the JNDI name" credit2 "in the
deployment descriptor. This matches the resource factory configured in the elements of the Web application, as described below.4. Configure the Tomcat resource factoryTo configure the resource factory for Tomcat, add such elements to the elements of the Web application. Context...>
...
Resourcename= "Jdbc/employeedb"Auth= "Container"type= "Javax.sql.DataSource"username= "Dbusername"Password= "Dbpassword"Driverclassname= "Org.hsql.jdbcDriver"
Today, tomcat5.528. Configure the data source connection pool, configure it on the Tomcat admin interface, write a Serverlet test, and report a cannot create JDBC driver of class ' for connect URL ' null ' ERROR,
Org.apache.tomcat.dbcp.dbcp.SQLNestedException:Cannot Create JDBC driver of class ' for connect
()){System. out. println ("name:" + rs. getString ("username") + "\ tpassword:" + rs. getString ("password "));}Rs. close ();Pstmt. close ();Conn. close ();} Catch (ClassNotFoundException e ){
E. printStackTrace ();} Catch (SQLException e ){
E. printStackTrace ();}
}}
5. Execute operations
If it is implemented using oracle, the code in the add class can be changedCode
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHig
Label:JDBC Core API Java.sql.* and Javax.sql.* |-Driver Interface: Represents the Java driver interface. All of the specific database vendors are going to implement this interface. |-Connect (URL, properties): A way to connect to a database. URL: The URL of the connection database
situation.3. Step three: Finally through the Tomcat Startup.bat boot and the Computer browser is able to see the successful connection to the data source and driver, but to start Tomcat with Eclipse can not be, always prompt cannot create JDBC driver ofClass ' for connect URL ' null ' problem, later found Tomcat+mysql problem, could not find
The first thing to know about JDBC: the technique of sending SQL statements using Java code is JDBC technology. That is, JDBC is an interface for different databases (Oracle, MySQL, SQL Server). ) of the operation. Prerequisites for sending SQL statements using JDBC:Log on to the database server (connect to the databas
All the configurations have been completed, and the server under eclipse can run. When the *. War package is output, it cannot run.
Jdbcexceptionreporter cannot load JDBC Driver Class ...... Error
After checking online, we can see that a similar error is successfully solved. The content is as follows:
Standardwrapper. throwableOrg. springframework. JDBC. cannotgetjdbcconnectionexception: cocould not get
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.