Posted in Data Structure

DDL, DML, DCL and TCL

DDL

(Data Definition Language)

DML

(Data Manipulation Language)

DCL

(Data Control Language)

TCL

(Transaction Control Language)

Create Select Grant Commit
Alter Insert Revoke Savepoint
Drop Update   rollback
Truncate Delete   Set transaction
Comment Merge    
Rename Call    
  Explain plan    
  Lock-table  
Advertisements
Posted in Core Java, Object Oriented Programming

Generics

A class, interface or method that declares one or more type variables (type parameters).

Advantages:

  • Type-Casting
  • Type-Safety (single type of objects)
  • compile-time checking

public Class Box{                                     ——–>              public Class Box<T>{

private Object obj;                                                                              private T t;

public void set (Object obj){                                                             public void set(T t){

this.obj=obj;                                                                                          this.t=t;

}                                                                                                        }

public Object get(){                                                                               public T get(){

return obj;                                                                                              return t;

}                                                                                                           }

}                                                                                                          }

Posted in database, Transaction isolation level

Transaction isolation levels

1 Read Uncommitted The user A start a query, then user B made some changes, A will see the changes have not been committed yet (dirty read)
2 Read committed The user A start a query, user B made some changes and commit. But A will not see the changes made by B.
3 Repeatable Read The user A will not see the changes made by B (insert/delete) read the snapshot established by the first read, so 2 queries executed, with 2 different results (phantom read).
4 Serializable All transactions are completely in isolation fashion, executed serially one after another (lock-based concurrency control).

In Oracle, Repeated Read level is not supported, but in MySQL default isolation level is repeated Read.

 

 

 

 

 

 

Posted in Java EE, JDBC

Statement vs. PreparedStatement in JDBC

Statement

PreparedStatement

for executing static SQL statements execute dynamic queries with parameter inputs
use String Concatenation to create the query and it can’t accept input parameters Use setter methods to set the input parameters for the query
Suitable for DDL  Suitable for DML
Slower Faster
  Prevent SQL Injection attacks