1. Create a table:
Create Table stud (Sid int,Sname varchar2 (50))Insert a data recordInsert into stud values (1, 'Tom ')
2. Define a cursor through the packageCreate or replace package pack_studIs-- Declare a cursor typeType cur is ref cursor;End;3. Create a stored procedure
Create or replace procedure pro_select_stud (My_cur out pack_stud.cur)IsBeginOpen my_cur for select * from stud;End;
4. Call in JDBC
Import java. SQL. callablestatement;Import ja
Because of Oracle commercial copyright issues, MAVEN cannot download jar packages directly through the central repository, and if you want to use jar packs, you need to manually process them.
Step One: Place the Ojdbc14.jar in the user's directory, such as: C:\Users\qicyt1812
Step Two: Execute the command in cmd: mvn install:install-file-dgroupid=com.oracle-dartifactid=ojdbc14-dversion=10.2.0.1.0- Dpackagin
driver package introduced in the demo, which includes the oracleconnectionpooldatasource class that implements the database connection pool., You need to go to the Oracle website to download according to your own database version (click to open the link ). The Code is as follows:
Pooldbsource class
Package COM. ***. connectionpool. DB; import Java. SQL. connecti
Label:Driver download Http://www.oracle.com/technetwork/topics/winsoft-085727.html Http://www.oracle.com/technetwork/cn/topics/winsoft-095945-zhs.html Oracle ODBC driver installation (no Oracle client installed) Recently done a project, through the VC ODBC access to the Oracle
Oracle transaction processing and instance demonstration JDBC operation batch Deletion
Transactions
As the basic unit of logical processing, database operations are composed of one or more SQL statements. Of course, there are also non-database operations, such as the Restore Point Set in the computer is a good application.
The basic nature of transactions is described in another article: SQL transactions an
user, String password );
Note: Obtain the database connection according to the url. the user is the username used to log on to the database, and the password is the login password.
Database url Description: The url is written as: localhost can be replaced by the return address 127.0.0.1 pointing to the Local Machine
Common Database url:
Oracle -- jdbc: oracle: t
Tags: cal creat png div src rest key cti User1, follow Oracle 2, CREATE DATABASE footsteps DROP TABLE person;
DROP SEQUENCE myseq ; //Set the self-increment sequence.
CREATE SEQUENCE myseq;
CREATE TABLE person
(
ID int. PRIMARY KEY not NULL,
name VARCHAR (#) not NULL,
age INT,
birthday DATE
); 3, then configure the driver. 4, execute: Get program: Dbdrive
PetaPoco Uses ODP. NET Managed Driver to connect to Oracle and petapocoodp.net
A few years ago, I used PetaPoco to work on an Oracle project. It was very troublesome to install the oracle client during development. After the environment is debugged, the system is not reinstalled until the end of the project. Recently,
No suitable driver found for jdbc:oracle:thin:@192.168.7.146:1521:oracleThe reasons for this error are mainly the following:1. URL configuration error (similar to the following)2. JDK version, JDBC version, and error caused by inconsistent database version.The first thing to ensure that your database supports the corresponding JDBC version, and then according to
The Blob field in Oracle is special. It has much better performance than the long field and can be used to save binary data such as sample slices.Writing Blob fields is very different from writing other types of fields. Because Blob itself has a cursor, you must use cursor to operate blob. Therefore, before writing Blob, you must obtain the cursor to write data. How can you obtain the Blob cursor?This requires you to insert an empty blob first, which
Oracle.jdbc.driver.OracleDriver.getConnectionInstance (oracledriver.java:442) At Oracle.jdbc.driver.OracleDriver.connect (oracledriver.java:321) At Org.apache.commons.dbcp.DriverConnectionFactory.createConnection (driverconnectionfactory.java:38) At Org.apache.commons.dbcp.PoolableConnectionFactory.makeObject (poolableconnectionfactory.java:294) At Org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory (basicdatasource.java:1247) At Org.apache.commons.dbcp.BasicDataSource.createDataS
dburl= "Jdbc:oracle:thin: @localhost: 1521:ORCL";//connecting to an Oracle databaseString username= "admin";//login account and password for the databaseString password= "Admin"; Connection=drivermanager.getconnection (Dburl,username,password); String SQL= "SELECT * FROM Student"; //Create a PreparedStatement object to send the parameterized SQL statement to the database. Preparedstatement=connection.preparestatement (SQL); RS=preparedstatement.execu
Document1. Download the oracle jdbc package, which is usually a jar package or zip package on the official oracle website.
Http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
2. Install the oracle jdbc package
When using this method, you need to add the Oracle jar package to the classpath variable. This package can be found in $ ORACLE_HOME/jdbc/lib/classes12.jar of the oralce client program.
Import java. SQL .*;
Public class jdbcthin {// Dburl database connection string information, where "1521" is the port and "ora9" is the SIDString dburl = "JDBC:
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.