Posts

Basics of Data Structures and Algorithms

Data Structure: Data Structure is a particular way of storing and organizing data in a computer. So, that it can be used efficiently. We can also say in the way of data structure is a special format for organizing and storing data. General data structure types include arrays, files, linked list, stacks, queues, trees, graphs and so on. Depending on the organization of the elements, data structures are classified into two types. Linear Data Structures:  Elements are accessed in a sequential order. But, it not compulsory to store all elements in sequentially. Ex: Linked List, stacks and Queues. Non-Linear Data Structures:  Elements of this data structures are sorted/accessed in a non-linear order. Ex: Trees and Graphs. Algorithms: The formal definition of an algorithm is the step-by-step instructions to solve a given problem. Let us consider the problem of preparing an omelet. For preparing omelet, general steps we follow are: Get the frying pan Get the oil a. Do we hav

Duplicate occurrences of characters in String without Collections

I have searched multiple websites to find the answer how to identify the duplicate characters in a given string " AMBERROADSOFTWARE " without using Collections API. But, still no luck. So, finally me and my team member Ramanjulu has found the way to solve this problem. This is also one of the question which is asking multiple companies interviews. package com . javatbrains . practice ; public class FindDuplicatesFromString { public static void main ( String [] args ) { findUniqueChars (); findDuplicateChar (); findDuplicateWords (); } private static void findUniqueChars () { String str = "NALLAMACHU" ; int count = 0 ; String finalString = "" ; if ( str != null ) { for ( int i = 0 ; i < str . length (); i ++) { char initialChar = str . charAt ( i ); int length = str . length (); str = str . replaceAll ( str . charAt ( i ) + "" , "" ); count =

java.sql.SQLException: ORA-00926: missing VALUES keyword

As part of Hibernate auto increment practice, I have entered into multiple issue. Here is the one of the exception which I had entered into is  java.sql.SQLException : ORA-00926: missing VALUES keyword . Stacktrace is as follows, Apr 10, 2017 4:48:37 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 926, SQLState: 42000 Apr 10, 2017 4:48:37 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: ORA-00926: missing VALUES keyword Apr 10, 2017 4:48:37 PM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release INFO: HHH000010: On release of batch it still contained JDBC statements Apr 10, 2017 4:48:37 PM org.hibernate.internal.SessionImpl$5 mapManagedFlushFailure ERROR: HHH000346: Error during managed flush [could not execute statement] Exception in thread "main"  org.hibernate.exception.SQLGrammarException : could not execute statement        at org.hibernate.exception.internal.SQLStateConve

ExceptionInInitializerError in Hibernate

As part of the Hibernate practice, I have faced the  Exception in thread "main" java.lang.ExceptionInInitializerError  at the time of creating the SessionFactory. Here is the full stacktrace which I have captured from console. INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException SessionFactory creation failed.org.hibernate.boot.registry.classloading.spi.ClassLoadingException : Unable to load class [com.javatbrains.sample.User] Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:13 )        at com.jtb.util.HibernateUtil.getSessionFactory( HibernateUtil.java:18 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException : Unable to load class [com.javatbrains.sample.User]        at org.hibernate.

SessionFactory creation failed.java.lang.NoSuchFieldError: namingStrategy

While creating the SessionFactory in Hibernate I have faced lot's of issues. This is also one the exception which I have faced, SessionFactory creation failed.java.lang.NoSuchFieldError: namingStrategy Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:13 )        at com.jtb.util.HibernateUtil.getSessionFactory( HibernateUtil.java:18 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: java.lang.NoSuchFieldError: namingStrategy        at org.hibernate.cfg.AnnotationConfiguration.reset( AnnotationConfiguration.java:237 )        at org.hibernate.cfg.Configuration.<init>( Configuration.java:125 )        at org.hibernate.cfg.Configuration.<init>( Configuration.java:119 )        at org.hibernate.cfg.AnnotationConfiguration.<init>( AnnotationConfiguration.java:96 )        at com.jtb.util.HibernateUtil.buildSessionFactory( Hiber

SessionFactory creation failed.java.lang.NoClassDefFoundError

While practicing the Hibernate auto increment example, I have faced lots of issues. In that one of the thing is SessionFactory creation error. Error stack trace is as follows, SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:15 )        at com.jtb.util.HibernateUtil.<clinit>( HibernateUtil.java:8 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory        at org.hibernate.cfg.AnnotationConfiguration.<clinit>( AnnotationConfiguration.java:65 )        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:12 )        ... 2 more Caused by: java.lang.ClassNotFoundException : org.apache.commons.logging.LogFactory        at java.net.URLClassLoad