Joined: Mon Sep 22, 2014 1:57 am Posts: 1
|
Hello Everyone! I am getting this exception in my java and hibernate code. Please share some ideas how to handle this.
org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132) at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:118) at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140) at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58) at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
Here is my code!
try {
int number = 0;
System.out.println("-------starting while loop------"); while (clientSocket.isConnected()) { System.out.println("====in the while loop===="); InputStream is = clientSocket.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader bfr = new BufferedReader(isr);
String n = bfr.readLine(); System.out.println("Read Line============================= " +n); char[] charArray = n.toCharArray(); for(int i=0;i<charArray.length;i++){ if((charArray[i]=='M')){ i=i+1; while (!(charArray[i]=='K')) { meter_no=((int)charArray[i])-47; System.out.println(i+"=====k==values====="+charArray[i]); i=i+1; } if(charArray[i]=='K'){ ArrayList<Integer> reading = new ArrayList<Integer>(); //int k=0; i=i+1; while (!(charArray[i]=='C')) { reading.add((int)charArray[i]); i=i+1; } CalculateBill cb = new CalculateBill(); System.out.println(2); meter_current_eading = cb.calculate(reading); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss"); readDate = sdf.format(date);
Map map = new HashMap(); map.put("meter_id", meter_no); System.out.println("Meeeteer no. " +meter_no); //sessionFac = new AnnotationConfiguration().configure().buildSessionFactory(); SessionFactory sessionFac = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = sessionFac.openSession(); Transaction tran = session.beginTransaction();
m.setMru_id(mruID); m.setMeter_id(meter_no); m.setMeter_reading(meter_current_eading); m.setReading_date(readDate);
session.save(m); if (!tran.wasCommitted()) tran.commit(); session.flush(); session.close(); sessionFac.close(); } } }
do { number = bfr.read(); ((MruToDB) currentThread()).kill(); } while (number == -1); System.out.println("===========comig down==========");
}
} catch (Exception e) { /*session.close(); sessionFac.close();*/ e.printStackTrace(); System.out.println("CLIENT THREAD:Client thread ended"); }
|
|