This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Shantanu Deshmukh

+ Follow
since Jul 28, 2011
Shantanu likes ...
Java jQuery PHP
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shantanu Deshmukh

@jan cumps,

I did that typo deliberately. to get that exception. only to find out that it is throwing nested exception. i want to find out a way to get inner exception class name
So this is the function I am going to use.

How can I use SQLException here?
6 years ago

I am trying to connect to mysql database. I am using try catch while establishing connection.
I want that I should be able to know what exception was caught, so that, I can show appropriate error message.
e.g if I pass incorrect hostname, i should show Wrong hostname provided.
One way to do is get class name of runtime exception class. but nested exception is being thrown like this..

There was some error while establishing connection to the databasecom.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

MESSAGE: localhsost

STACKTRACE: localhsost
at Method)
at com.mysql.jdbc.StandardSocketFactory.connect(
at com.mysql.jdbc.MysqlIO.<init>(
at com.mysql.jdbc.Connection.createNewIO(
at com.mysql.jdbc.Connection.<init>(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at accessMySQL.accessMySQL.createConnection(
at test.main(


Last packet sent to the server was 1 ms ago.
Problem in establishing connection.

Now I would like to know that class name UnknownHostException, so I can setup a condition like

please help !!

I am trying to connect to mysql database using JDBC. I have applied exception handling. However simply printing exception object is amateur. I want to know exact reason of exception.
For example, if I give wrong hostname it should give me exception that Hostname was incorrect.
How to go about it ?

6 years ago
I am trying to write a function which takes stored procedure's name and it's arguments as argument and execute it.
Now I want that, the function should be able to know wat data is being output from the sp, so I can set datatype of output variable of sp.

How to do this ?
Hello, I have this function which calls a stored procedure

executing this function gives me this error:

There was some error while making Prepared Call.
Error Descrption: java.sql.SQLException: Callable statments not supported.

Please help !!
Hey folks, got a solution for that.
zeroDateTimeBehavior=convertToNull add this as a parameter in JDBC connection url to slove this problem

Hope this helps to whoever reaching to this problem
I am writing a simple jdbc program, which will print data column in my table. I use this statement users.getString('update_time')
The field in my database contains, for e.g, this value 2010-01-12 20:54:35.0.
The program prints this value, but also throws exception as Cannot convert value '0000-00-00 00:00:00' from column 7 to TIMESTAMP.

Please help !!
hi all, thanks for your input.
The connection URL was wrong in the program. I also had not included com folder provided with the connector. This all is working in Eclipse now.
Still not much clue how to run it all on command prompt.
I am also trying on eclipse. There I get No suitable driver found for the same program. i have imported external JAR, that mysql connector one. no luck there either.
by the way is this url format wrong ?

this is the command
java -cp /home/shantanu/DEV_DOCS/SOAP/mysql-connector-java-5.0.8-bin.jar:. acessMySQL

this is the error:

Exception in thread "main" java.lang.NoClassDefFoundError: acessMySQL
Caused by: java.lang.ClassNotFoundException: acessMySQL
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
Could not find the main class: acessMySQL. Program will exit.
Hey vijay, thanks for that hint.
But now I am getting class not found exception !! the path I just gave is the same path where my class file lies. What else could I be missing.
I understand now, that the basics like classpath, java_home are not that clear to me. please help me if I am wrong with them, in this case.
(I really want to learn java, lest I clear these obstacles )
I m doing everything you folks are telling me. I entered this command while compiling

compiled with no errors.

While running:
java -cp /home/shantanu/DEV_DOCS/SOAP/mysql-connector-java-5.0.8-bin.jar;. acessMySQL

I am showing full list of java options !!! why isn't this working ???
i wrote the exact command you gave me, but then all options related to java command were shown, meaning it was not a correct command or did not have correct options.

sorry for bugging, but more help needed. I am on this since the whole day, but cant get it to work !!
I hit this command

java -cp /home/shantanu/mysql-connector-java-5.0.8-bin.jar accessMySQL

and now it give me class not found exception java.lang.ClassNotFoundException: accessMySQL

help !!