The following code shows the use of some sqlexception method
package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery("select stateId,stateName from statesz"); rs.last(); System.out.println("Number of rows:"+rs.getRow()); } catch (SQLException e) { System.err.println(e); System.err.println("Error message:"+e.getMessage()); System.err.println("Error code is:"+e.getErrorCode()); System.err.println("sql state:"+e.getSQLState()); } finally{ if(rs!=null){ rs.close(); } if(stmt!=null){ stmt.close(); } if(conn!=null){ conn.close(); } } } }
A string describing the error. This is used as the Java Exception message, available via the method getMesasge.
ReplyDeletea "SQLstate" string, which follows either the XOPEN SQLstate conventions or the SQL:2003 conventions. The values of the SQLState string are described in the appropriate spec.
The DatabaseMetaData method getSQLStateType can be used to discover whether the driver returns the XOPEN type or the SQL:2003 type.
an integer error code that is specific to each vendor. Normally this will be the actual error code returned by the underlying database.a chain to a next Exception.
This can be used to provide additional error information.the causal relationship, if any for this SQLException. Java training in chennai | Android training in chennai
Excellant content thanks for sharing the unique information and keep posting.
ReplyDeleteAndroid Training in Chennai | android courses in Chennai | FITA Velachery | FITA Training
Are you a fresher or student searching your first dream job or are you an experienced working professional seeking for an opportunity to change your current working company or job role? Why don't you make the changes your career on java
ReplyDeleteJAVA Training in chennai
This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.. Android Training in Chennai || Android Courses in Chennai || Android Certification in Chennai
ReplyDeleteThanks a lot for all your valuable article! We are really happy about the your... ANDROID Training in Chennai
ReplyDeleteThis java basics are good.It is very useful for me.
ReplyDeleteSAP ABAP Training in Chennai
The sql exception method is very important one in java. This blog clearly explains the sql exception in java and giving the coded examples. Thanks for this blog. very useful one.
ReplyDeleteInformatica Training in Chennai
This blog is informative. It explains about the sql exception in java which helps the freshers to learn easily. the concept was clearly explained.
ReplyDeleteManual Testing Training in Chennai
Its more informative..Clearly explained about How to use exception method in java..Its more informative and useful.Keep on blogging like this..
ReplyDeleteAndroid Training in Chennai
It is very intelligent information.It is clearly explained the SQL exception methods used in java.
ReplyDeleteJava j2ee Training in Chennai
very much useful information you are sharing about basics of java and with its architecture explanations.
ReplyDeletekeep sharing.
Loadrunner Training in Chennai
this blog is informative , i am really very happy to know about the information of java which i have already learned , thanks for sharing this information.
ReplyDeletedot net training in chennai
Nice blog..Its more useful blog about How to use SQL Exception Methods in java..Its more informative and useful..Keep on sharing..
ReplyDeleteLinux training in chennai
Thank you for this brief explanation and ver nice information. well, got a good knowledge. Have a nice idea, this is more helpful to me. This can gives the better performance.
ReplyDeleteInformatica Training in Chennai
This blog provides an detail explanation about the sql exception and its techniques. Thanks for posting this information.
ReplyDeletessrs training in chennai
valuable information.SQL exception in Java and is useful for me.It is more explained in programming or coding way.
ReplyDeleteSharepoint developer training in chennai
ReplyDeleteAll are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
Java training in Adyar
This article provides the information about Java its key features and scope for java professionals. This information is really helpful me to know more about Java programming language. Java Training in Chennai | Java Training | Java Course in Chennai
ReplyDelete