CompEng
CompEng

Reputation: 7376

How can I get error message?

I want to oracle dabase connection with java. I use this code :

url = statement;
try {
    stmt = connection.createStatement();
    rset = stmt.executeQuery(url);
} catch (Exception e) {
    // what can I put here?
}

And when my statement cause error in oracle I want to get error message. How can i do this?

Upvotes: 1

Views: 9794

Answers (4)

markus
markus

Reputation: 602

try to use e.getLocalizedMessage()

Upvotes: -1

Rakku Muthu
Rakku Muthu

Reputation: 31

Try using this piece of code:

e.getMessage();

Upvotes: 1

ChrisHarris2012
ChrisHarris2012

Reputation: 404

A simple Google search reveals:

JDBC Exception handling is very similar to Java Excpetion handling but for JDBC, the most common exception you'll deal with is java.sql.SQLException.

Check out their example here

Good Luck!

Upvotes: 1

user1577870
user1577870

Reputation: 126

You can use e.getMessage(); I believe

Upvotes: 5

Related Questions