- 浏览: 236202 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
akka_li:
学习了!但是为什么后续的没有了?!
EJB4:RMI和RMI-IIOP -
springaop_springmvc:
apache lucene开源框架demo使用实例教程源代码下 ...
Lucene学习笔记(一)Lucene入门实例 -
qepipnu:
求solr 客户端 jar包
Solr学习笔记(三)Solr客户端开发实例 -
zhangbc:
是这问题,赞!
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题 -
feilian09:
查询 select hibernate jdbc 那个效率快
Hibernate,JDBC性能探讨
The Following Exception is really Frequency When we Using Oracle.
1. ORA-02292: integrity constraint (IPCUSER.STUDENT_STUDENTCARD_FK) violated - child record found
If you delete a row from a table, and one of this row's columns referenced by another table, and then this Exception been throwed.
the stacktrace info:
java.sql.SQLException: ORA-02292: integrity constraint (IPCUSER.STUDENT_STUDENTCARD_FK) violated - child record found at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745) at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210) at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:961) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190) at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1726) at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1696) at com.tibco.ipc.utils.TESTClient.main(TESTClient.java:48)
2. ORA-02291: integrity constraint (IPCUSER.STUDENT_STUDENTCARD_FK) violated - parent key not found
If you insert a row to a table(table_a), and this row has a foreign key refered to another table(table_b), and the foreign key's value can not be found from another table(table_b), then this Exception been thowed.
the stacktrace info:
java.sql.SQLException: ORA-02291: integrity constraint (IPCUSER.STUDENT_STUDENTCARD_FK) violated - parent key not found at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745) at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210) at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:961) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190) at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1726) at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1696) at com.tibco.ipc.utils.TESTClient.main(TESTClient.java:48)
3. ORA-00001: unique constraint (IPCUSER.STUDENTCARD_HID_PK) violated
If you insert a row to a table, one of this row's column is primary key, and if the primary key you want to insert already existed in table, this Exception been throwed.
The StackTrace info:
java.sql.SQLException: ORA-00001: unique constraint (IPCUSER.STUDENTCARD_HID_PK) violated at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745) at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210) at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:961) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190) at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1726) at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1696) at com.tibco.ipc.utils.TESTClient.main(TESTClient.java:46)
4.ORA-01591: lock held by in-doubt distributed transaction 8.12.9742
The stacktrace information:
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
Refering to this Exception, We should learn this fllowing issues firstly, before we discussing this point:
1> Understanding 'Oracle two-phase commit mechanism':
Two-phase commit is a mechanism that guarantees a distributed transaction either commits on all involved nodes or rollback on all involved nodes to maintain data consistency across the global distributed database. It has two phase, a Prepare Phase and a Commit Phase. The Objective of the two-phase commit mechanism is that that all nodes either commit or perform a rollback together, to maintain the data's integrity and consistency.
2> Oracle distribution Transaction
To make this issue more explicity and clearly we providing the following experiments:
As figure depicted, 2 JDBC Connection in different JVM connected to the same databse, and update the same table's same row. Assuming the table name is 'HOMETEST', the row is 'Row 1', 'HOMETEST' is very simple, the create SQL statements:
CREATE TABLE HOMETEST( HID NUMBER(19,0) CONSTRAINT HOMETEST_HID_NN NOT NULL, NAME VARCHAR2(255), CONSTRAINT HOMETEST_HID_PK PRIMARY KEY(HID) )
Two JVM update table's procedure is very samilary, like the following figure depicted:
continuely assuming: JVM I and JVM II update row 1 cosistantly and simultaneously, JVM I,eachtime change row 1's column 'NAME''s value add 1 and without stopping; Oppositely; JVM II, eachtime reset row 1's column 'NAME''s value, and exist without commit in the 10th time. reserence Java Code:
JVM I:
int i = 1; Connection conn = getConnection(); Statement s = null; while(true) { String upSql = "UPDATE HOMETEST SET HOMETEST.NAME = 'kylinsoong-" + i + "' WHERE HOMETEST.HID = 1"; try { conn.setAutoCommit(false); s = conn.createStatement(); s.executeUpdate(upSql); int sleep = new Random().nextInt(100); System.out.println("Update Thread Sleep " + sleep + " milliseconds"); Thread.sleep(sleep); i ++ ; conn.commit(); } catch (Exception e) { e.printStackTrace(); } finally { close(null, s, null); }
JVM II Sides:
int index = 1; while(true) { try { conn.setAutoCommit(false); s = conn.createStatement(); s.executeUpdate(rmSql); s.executeUpdate(adSql); int sleep = new Random().nextInt(100); System.out.println("Insert Thread Sleep " + sleep + " milliseconds -> " + index); Thread.sleep(sleep); if(index ++ == 10) { Thread.sleep(60000); break; } conn.commit(); } catch (Exception e) { e.printStackTrace(); } finally { close(null, s, null); } }
The Experment Results:
When JVM II executed the 10th times update, sleeping 1 minute, the JVM I also in stucked state;
The finally value in row 1 Name column is always kylinsoong-10, even after JVM I stopped. That's because JVM I and JVM II update row 1 are totally involved, JVM II could not update row 1 if JVM I transacted row 1.
The Conclusion: The Oracle distribution Transaction is not real distributed, All involved Node always in a order list, execute order list base on FIFO, in other words, Oracle distribution Transaction just like run multiple-thread application in single process mechine.
3>
发表评论
-
Oracle - Add Exist Validation Before Create Table
2011-11-07 13:49 1405Usually we need to check the ta ... -
Oracle - An Managing Lob examples
2011-10-30 17:28 1383I met a request: I need to read ... -
PL/SQL Studing Notes
2011-10-20 21:48 1327As an extension of native ... -
一组Linux命令
2011-09-29 13:09 1426今天做测试发现Oracle服务器磁盘使用率达到100%导致Or ... -
Thinking in JDBC
2011-09-22 20:56 1817This blog will beas on a series ... -
SQL Studying Note I - Join
2011-07-02 10:28 1183SQL Join SQL Join are u ... -
Windows批处理脚步实例-创建Oracle数据库用户并向该用户添加数据
2010-12-11 09:25 3396Windows批处理使用方便、 ... -
Oracle starting up 5: Oracle 10g在WINDOWS服务中有5个Oracle服务项及解决与服务项相关的几个问题
2010-10-10 17:25 2292在Windows下安装Oracle 10g,安装完后在WIND ... -
Oracle starting up 5: Oracle数据库基础(续)
2010-10-07 14:15 0通用函数; 通用函数用于任何类型数据(包括空值) ... -
Oracle starting up 4: Oracle 10g 客户端 enterprise manager console 消失问题
2010-10-06 15:20 4262在家装了台服务器,因为家里电脑不行,所以服务器和客 ... -
Oracle Start Up 3:Oracle数据库基础
2010-10-05 20:17 21281. 创建TableSpace、用户及给用户分派权限 ... -
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题
2010-10-02 14:07 34663Warming Up: 本文 ... -
Oracle Start Up 1: 几个概念和Oracle数据库的物理结构和逻辑结构
2010-09-29 23:31 1984Oracle 基本概念 数据库(Database) ... -
Oracle 连接错误;ORA-27101: shared memory realm does not exist
2010-09-28 14:27 26274XP下安装Oracle10g 昨天下午刚安装完可以连接(Sq ... -
SQL Server 2005 dev 学习(1)
2010-09-26 15:14 1938关键字:SqlServer2005Dev版本安装 SQL Se ... -
Cassandra Dev 3:Cassandra 应用之CassandraAppender
2010-08-13 13:59 2034本文的目的是展示 ... -
Cassandra Dev 2: Cassandra入门(续) - Cassandra Cluster
2010-08-09 13:56 57235. Cassandra CLI 一般数据库服务器都会提供一 ... -
Cassandra Dev 1: Cassandra 入门
2010-08-06 17:55 4563最近, Cassandra 绝对是一个比较前端的话题 ...
相关推荐
oracle常见Exception;oracle常见Exception;oracle常见Exception;oracle常见Exception;
Oracle Exception汇总(自定义Oracle异常) 使用方法举例: Exception When no_data_found then Dbms_output.put_line(‘no_data_found’); ACCESS_INTO_NULL 为对象赋值前必需初始化对象。对应ORA-06530错误。 CASE...
ORACLE SQL Reference 10g ORACLE SQL Reference 10g ORACLE SQL Reference 10g
Oracle_存储过程exception异常处理大全及实例经典最终.docx
Oracle SQL Reference.pdf
Oracle SQL Reference命令参考文档,Oracle官方出品,以自动机的形式描述SQL Plus中各个命令的详细用法,超过1000页的文档
Oracle Database Reference 10.2.pdf 好工具书。
Oracle Service Technical Reference Manual
Oracle内置包_reference,ocacle内置开发包,用于oracle数据库的开发,详细介绍oracle数据库的开发。
Oracle® Database Reference.pdf
oracle sql reference about how to use oracl sql
全面 丰富的 oracle sql 手册
This manual provides reference information about database initialization parameters, static data dictionary views, dynamic performance views, database limits, and SQL scripts that are part of the ...
《Reference for Oracle GoldenGate for Windows and UNIX》参考文档,涉及到内容Oracle GoldenGate参数详解。
OracleDatabase SQL Reference OracleDatabase SQL Reference OracleDatabase SQL Reference
Oracle SQL*Plus Pocket Reference, 2nd Edition Copyright Oracle SQL*PlusPocket Reference Section 1.1. Introduction Section 1.2. Interacting with SQL*Plus Section 1.3. Selecting Data Section 1.4. ...
Oracle Database 12c The Complete Reference Word文档版,包含表格创建以及演示代码。
非常有用的oracle sql字典。包含所有的sql命令,方便查询
Oracle 10G DBA Reference.chm
ORACLE11G SQL Language Reference ....... e41084