To select records using Statement in java we use
1 |
ResultSet executeQuery(String sql) throws SQLException |
To select records using Statement in java we use
1 |
ResultSet executeQuery(String sql) throws SQLException |
We saw how to Create a table and Insert Data using Statement in Java. Now lets delete some of the data from the table using Statement. Delete record SQL Below is the query that can be fired directl
We saw how to Create a table and Insert Data using Statement in Java. Now lets update the data into that is already present in the table using Statement. Update record SQL Below is the query that c
We saw how to Create Table using Statement in Java. Now lets insert data into this table using Statement. Insert record SQL Below is the query that can be fired directly on database to insert recor
Statements in JDBC are used to execute SQL statements that do not require dynamic parameters passed to the query. Lets see how to create create table using statement in java. Please note : We will
In this post we will see the sample code to connect to MySQL using JDBC drivers in java. For connecting to MySQL database we will need the following 1. Connection URL The format is [crayon-68eb6220
Rethrowing of exception in java has improved starting from Java 7. We can now specify more specific exceptions using throws keyword. Before java 7:
1 2 3 4 5 6 7 8 9 10 11 12 |
public void someMethod(String testStr) throws Exception { try { if (testStr.equals("SomeThing")) { throw new UserException1(); } else { throw new UserException2(); } } catch (Exception e) { //Do some processing.. throw e; } } |
Catching multiple exceptions in java is now very easy starting from Java 7. Before java 7 we used to write the below code for catching multiple exceptions
1 2 3 4 5 6 7 8 9 |
try{ //Some Statements }catch(Exception1 e1 |){ //log statements }catch(Exception2 e2){ //log statements }catch(Exception3 e3){ //log statements } |
Throws keyword in java is used to declare exceptions that can be thrown by the method. Throws keyword can be used to throw multiple exception. syntax: 1. Throws single exception [crayon-68eb6220b69
Exceptions in java can be thrown using the “throw” keyword. The throw statements requires a object to throw. This object needs to be a throwable object. Syntax: [crayon-68eb6220b6c0f015