Categories

Main
Database
Java
Microsoft.NET
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
ColdFusion
Crystal Reports
Delphi, C etc
JAVA
Microsoft.NET
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
XML & XSLT
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
Applications & Tools
Database Concepts & Design
EJB programming & troubleshooting
EJB design
General J2EE
XML & Web services
Web tier: servlets, JSP, Web frameworks
Performance and scalability
Industry news
TSS feedback
Mobicents Contributors
Mobicents Users
JSLEE Resource Adaptor Types
Planning JavaOne 2008
Sun Tech Days
Other Java conferences
Binary Web Services and XML
Metro and JAXB
GlassFish
GlassFish Plugins
Project jMaki
GlassFish WebTier
Mural
Java Development Tools
Java WS & XML Community News
JAXP
Java SE
6uN Early Access
Java Quick Starter
Java SE Snapshots: Project Feedback
JCK Forum
Feedback and Suggestions
JDK Distros
JDK Open Source
General JSR Discussion
JCP 2.6
JXTA Community Forum
ME Interest
ME Cool Apps
ME General Help
ME Feedback & Suggestions
ME Application Developer Interest
Blu-ray Disc Java
ME Developer Days
Squawk
Mobile Developer Alliance
OpenCable
LWUIT
JavaFX Script Language Discussion
OpenJFX General Discussion
Scene Graph
General Performance Discussion
Your Java Career
NetBeans 6.0
Servlets
JSP
JSF
Portals and Portlets
EJB and Other Java EE Technologies
Distributed Java
Object Relational Mapping
JDBC
Web Services
Swing / AWT / SWT / JFace
JNLP and Web Start
Java Micro Edition
Sockets and Internet Protocols
Threads and Synchronization
Performance
Applets
I/O and Streams
Other Java APIs
Game Development
Java in General (beginner)
Java in General (intermediate)
Java in General (advanced)
Programmer Certification (SCJP)
Developer Certification (SCJD)
Associate Certification (SCJA)
Web Component Certification (SCWCD)
EJB Certification (SCBCD)
Mobile Application Certification (SCMAD)
Architect Certification (SCEA)
Web Services Certification (SCDJWS)
XML Certification
Product and Other Certifications
Mock Exam Errata
Sun Certification Results
Authors' Corral
Book Reviews
Events
Bunkhouse Porch
Teachers' Lounge
Testing
OO, Patterns, UML and Refactoring
IDEs, Version Control and other tools
Ant, Maven and Other Build Tools
Linux / UNIX
Mac OS
HTML and JavaScript
XML and Related Technologies
Agile and Other Processes
General Computing
Security
Groovy
Scala
Other Languages
Struts
Application Frameworks
Other Open Source Projects
BEA/Weblogic
IBM/Websphere
Oracle/OAS
Apache/Tomcat
JBoss
Other Java Products and Servers
JavaRanch
Cattle Drive (java college)
Moderators Only
Trash Can
Jobs Offered
Jobs Wanted
Jobs Discussion
Meaningless Drivel
Programming Diversions
Blatant Advertising
Java Announcements
New To Java
Advanced Java
Java Applets
Networking
Threads and Synchronization
Java 2D
AWT / Swing
SWT / JFace
CLDC and MIDP
CDC and Personal Profile
Sun Java Wireless Toolkit
Enterprise JavaBeans
JavaServer Pages (JSP) and JSTL
Java Servlet
JavaServer Faces
Web Frameworks
Database
XML
Lucene
NetBeans
Eclipse
IntelliJ IDEA
JCreator
Other IDEs
Java Tutorials
Java Tips
Jobs Discussion
Jobs Offered
Jobs Wanted
Professional Certification
Forum Lobby
Java Blogs
Introductions
Reviews / Advertising
Suggestions & Feedback

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

JDBC

Database access, JDBC/ODBC, could even brush on some SQL

Capturing SQLSTATE Messages


I'm coding an application that does an INSERT into a database that triggers a delete on another record.  Currently, the application has no way of letting the user know whether or not the triggered delete worked, only whether the INSERT failed.The coworker who will be coding the trigger said that he would set the trigger to send a SQLSTATE message indicating whether or not the triggered delete (after the successful insert) worked.My question is how do I capture this SQLSTATE message so that I can send it back to the user as an error/notification message?   Will the SQLSTATE trigger an exception, or will I have to use some part of the JDBC API to capture this message.--------------------Sun Certified Programmer for the Java 2 Platform

   
   

   
   
      Hi Gabriel,I don't know what database you are working with (I didn't see any mention of it in your post), but with the Oracle 8i database that I work with, database triggers _always_ (as far as I know) execute in the same transaction context as their triggering event.In other words, you cannot have a situation where the DELETE operation worked, but the INSERT operation failed. If the INSERT succeeded, then the DELETE also succeeded (and vice-versa).However, a DELETE operation may not delete any rows (since there were no rows matching the DELETE criteria). In this case -- for all the databases I have worked with -- this is _not_ considered an error.[That's why the "executeUpdate()" method -- in the "java.sql.Statement" class -- returns an "int" indicating how many rows were affected.]So if you want to know how many rows the DELETE operation actually deleted, then I don't think that this information is available via SQLSTATE, anyway.So unless I've totally misunderstood your question, I think you're barking up the wrong tree, and you need to rethink this issue/requirement/problem.Hope this helps.Good Luck,Avi.


Related Links

JDO real world implementation question
The price of JDO
Does the book cover the Object Oriented design?
DB constraints and composite primary keys
Using Connection Pool To Access MySQL Database On Tomcat
Using JDO with an existing DB schema
connection pooling/oracle/multiple jvms
Welcome David Jordan and Craig Russell to our Book Promotion of the Week
setAutoCommit(autocommit);
JDO's Future Versions and Standardization.
Index not used on Tables in views
Java Data Objects - Chapter 1
JDO in other languages ?
What Should I Download To Use the Oracle 9i?
is JDO for RDBMS only or does it work with other types of datastorage, too?
JDO vs other persistence mechanism