Import java.sql.*;
The packages used in JDBC are almost always in import?java.sql.*;
Import Oracel or MySQL packages and load drivers in your project:
The classpath of the project and the classpath of the system are put in classpath, if it is placed in the classpath of the system, if the version is different, it may interfere with the different projects in the system, put under the project, reduce the coupling between the project
Java. Lang. nullpointerexceptionAt oracle. JDBC. Driver. scrollableresultset. Close (scrollableresultset. Java: 149)At org. Apache. tomcat. DBCP. DBCP. delegatingresultset. Close (delegatingresultset. Java: 152)At com. Unify. Common. Page. exportalldata (page. Java: 234)
.....
The following is useful information (COM. Unify. Common. Page is a class written by ourselves)
I encountered this problem today a
Xuzhou needs to connect to a third-party database. The original database uses a Windows Cluster and is recently changed to the RAC mode, leading to frequent JDBC connection errors. Solution:
1. connection string Configuration:
JDBC: oracle: thin: @ (description = (address_list = (address = (host = IP address 1) (Protocol = TCP) (Port = 1521 )) (address = (host
Oracle Problem Description: The following error occurred while using JDBC to connect to the Oracle database: Connection refused (description= (tmp=) (vsnnum=153093120) (err=12505) (Error _stack= (Error= (code=12505) (emfi=4)))
and directly through the Sqlplus or Toad can connect the database, after the debug and find the relevant data to find the cause of the
The driver packages from Oracle8 to ORACLE10,JDBC directories are different. Look at Oracle's documentation, understand their use, I believe you are sometimes very confused, write to share.
These are the names of the driver packages under oracle10g and their role, and other versions of Oracle are basically similar.
Classes12.jar (1,417,089 bytes)-Use under JDK 1.2 and JDK 1.3
Classes12_g.jar (1,794,418 byte
Import the database jar package with the following path:E:\oracle\product\10.1.0\Db_3\jdbc\lib\ojdbc14.jarThe table statement is as follows:CREATE TABLE T_user (ID int PRIMARY KEY,Username varchar (40),Password varchar (16),Phone varchar (40),Address varchar (255),CreateDate Date)The JDBC code is as follows: Public void Save () {Connection con=db. getconnection (
Error"); About e.printstacktrace (); $ }
- }
-
- Private StaticConnection connectionget () A {
+Connection conn =NULL;
the Try
- {
$conn =drivermanager.getconnection (URL, user, password); the }
the Catch(SQLException e) the {
theSYSTEM.OUT.PRINTLN ("Database link Error"); - e.printstacktrace (); in }
the returnConn; the }
About
the Private Static voidClose (ResultSet rs, Statement stmt,
A simple example shows Oracle's "selfless" robustness, and the example oracle is selfless.
Oracle's strength lies in its ability to always help you choose the right execution plan, even if you give it wrong instructions.
Lab:
1. Create a test table:
Collect statistics:
Create a B-Tree Index:
2. Execute select id from tbl_plan; to view its execution plan:
oracle| Access
1. The connection was very slow, and an exception occurred while performing a select operation after the connection was successful:
Exception in thread "main" java.sql.sqlexception:ora-00600: Internal error code, parameters: [ttcgcshnd-1], [0], [], [], [], [], [], []
Resolution: Normal after using Jdbc\lib\classes12.jar under the Oracle ins
In the SPRINGMVC framework, Oracle Data sources are configured in Spring-servlet.xml as follows:
destroy-method= "Close" >
The exception is as follows:
caused by:org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection; Nested exception is org.apache.commons.dbcp.SQLNestedException:Cannot create JDBC driver of class ' Oracle.jdbc
1, to the database, the table of each row of data record additions and deletions to changeAdd: INSERT into Table name values ()Delete: Delete table name where condition (id=? )Change: Update table name set column name =? Where Condition (id=? )Check: Select column name from table name where id=? Look up a piece of informationSelect Column name from table name order by ID check all information2. ResultSet result setis an interface that points to a pointer to the current data row, starting at the
JDBC inserts data into the database to obtain the primary key. Currently, I have summarized two methods:1. Applicable to databases with auto-increment columns (such as SQL-server and mysql)/*** Insert data to obtain the primary key* @ Param annex* @ Return*/Public long save2 (Annex annex ){Long queue id = 0;// Obtain the connectionConnection con = ProxoolManager. getConnection ();String insertSQL = "insert into annex values (?,?, Sysdate ,?,?,?) ";Pre
Maven oracle jdbc jar, mavenjdbc
1. problem describe:
When you dependency jar about oracle use code like this:
You will not really get jar through maven, because you don't have permission to get the jar.
2. sulution:
You can get the jar from some web site, and then install it to you local maven repository.
Now I put my jar to D: ojdbc14.jar
1. The connection was very slow, and an exception occurred while performing a select operation:
Exception in thread "main" java.sql.sqlexception:ora-00600: Internal error code, parameters: [ttcgcshnd-1], [0], [], [], [], [], [], []
Workaround: Normal after using the Jdbc\lib\classes12.jar under the Oracle installation directory.
2. Occurs when using the SetString (I, s) of PreparedStatement:
can refer t
driverSystem.out.println ("Start trying to connect to the database!") "); String URL= "Jdbc:oracle:" + "thin:@127.0.0.1:1521:xe";//127.0.0.1 is a native address, XE is the default database name for Lite OracleString user = "System";//user name, system default account nameString Password = "147";//The password you selected when you installed the settingscon = drivermanager.getconnection (url, user, password);//Get ConnectionsSYSTEM.OUT.PRINTLN ("Connection Successful! "); String SQL= "SELECT * f
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.