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
Update record using Statement in Java
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
Insert record using Statement in Java
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
Create Table using Statement in Java
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
Connect to MySQL using JDBC
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-69e045e6
Rethrowing of Exception in Java
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
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 in exception handling in java
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-69e045e67d0
How to Throw exception in java
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-69e045e67d3c8163
Try Catch Finally in Java Exception handling
In this post we will see the exception handling using the try catch finally in java. 1. Use of Try – Catch Block A exception in java can be handled using a Try and Catch block. Lets see a sim