Create SessionFactory in Hibernate 4

We can create SessionFactory in Hibernate 4 latest version, viz Hibernate 4.3.8 till now using the StandardServiceRegistryBuilder class. In prior version of hibernate we build the SessionFactory something like this SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); But the class org.hibernate.cfg.Configuration.buildSessionFactory() is deprecated in latest version of Hibernate. For more information you can go to the Hibernate … Read more

List All Column Names of Table using Java

We can list all column names of table using java.sql.DatabaseMetaData.getColumns() method. The getColumn method accepts String catalog, String schemaPattern, String tableNamePattern and String columnNamePattern parametres. It retrieves a description of table columns available in the specified catalog. The method return ResultSet where each row is a column description. Example to list all column names of … Read more

List All Table Names of Database using Java

We can list all table names of database using java.sql.DatabaseMetaData.getTables() method. The getTables method accepts catalog, schemaPattern, tablenamePattern, types parameters and returns ResultSet where each row is table description. Each table descriptor contain the following columns: String TABLE_CAT represents table catalog and can be null String TABLE_SCHEM represents table schema and can be null String … Read more

Check if Database Exists using Java

We can check if database exists using java.sql.DatabaseMetaData interface. using DatabaseMetaData interface we can obtain the meta data about the database catalog, for example we can obtain the database name, tables available in that database, columns in that table etc. The getCataLogs() method which is called on the instance of  DataBaseMetaData, retrieves the catalog name … Read more

Create JDBC Connection using Properties File

In this tutorial we will create jdbc connection using properties file. Properties file is a convenient way to store the data in key value pair. in properties file both key and values are of String type. We are storing the connection parameters in the properties file because we can manage the properties file very easily. … Read more

Configure log4j using properties file in Java

Log4j is a logging framework based on Java, It is an open source logging framework designed to manage application logs in a flexible and efficient manner. Configuring Log4j with Properties File:- One of the key features of Log4j is its easy configuration. To set up Log4j using a properties file, developers can rely on the … Read more

Get All Key Values from Properties File

Get All Key Values from Properties File Get All Key Values from Properties File in java using the Properties class Available in java.util Package. The Properties class extends the Hashtable class. From Hashtable, Properties class inherits the Method KeySet() which Returns a Set view of the keys Contained in this Map. Project Structure:- Example to … Read more

Read Properties File using java

To Read Properties File in Java, the Properties Class has a Convenient load Method. That’s the Easiest Way to Read a Java Properties File. Properties are Configuration Values Managed as key/value Pairs. In Each Pair, the key and value are Both String Values. The key Identifies, and is Used to Retrieve, the Value, much as … Read more

Network Interface Addresses Listing

We can get the list of IP addresses that are assigned to it using a network interface. Network interface addresses can be obtained from a NetworkInterface instance by using one of two methods. The first method, getInetAddresses(), returns an Enumeration of InetAddress. The other method, getInterfaceAddresses(), returns a list of java.net.InterfaceAddress instances. This method is … Read more