Saturday, December 28, 2013

java.lang.UnsupportedOperationException: The application must supply JDBC connections.


Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections.

Problem:   
while setting jdbc connection property by using annotation configuration we need to add hibernate in preceed of property.
AnnotationConfiguration config = new AnnotationConfiguration().addAnnotatedClass(User.class);
       config.setProperty("connection.driver_class", "oracle.jdbc.driver.OracleDriver");
       config.setProperty("connection.url", "jdbc:oracle:thin:@localhost:1521:xe");
       config.setProperty("connection.username", "ranga");
       config.setProperty("connection.password", "ranga");

Solution:
AnnotationConfiguration config = new AnnotationConfiguration().addAnnotatedClass(User.class);
       config.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
       config.setProperty("hibernate.connection.url", "jdbc:oracle:thin:@localhost:1521:xe");
       config.setProperty("hibernate.connection.username", "ranga");
       config.setProperty("hibernate.connection.password", "ranga");  

0 comments: