Skip to Content
0

how to establish connection to hana cloud database using jdbc java and deploy it on hana cloud

Oct 12, 2017 at 06:54 AM

110

avatar image
Former Member

i had created a trail account in SCP, i want to connect to hana cloud database by creating java web project(jdbc connection to HANA cloud DB) in eclipse IDE

i already have a connection details but i'm not sure that those are correct or not

Connection con = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.sap.db.jdbc.Driver"); con = DriverManager.getConnection("jdbc:sap://localhost:30315?reconnect=true&timeout=0", "<AKSHAYB>", "<Indirab@1234567>"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM EMPLOYEE"); while (rs.next()) { response.getWriter().println(rs.getString(1) +" | "); response.getWriter().println(rs.getString(1) +" "); System.out.print(rs.getString(1) + " | "); System.out.print(rs.getString(2) + " "); } rs.close(); stmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } }

using this i'm getting an exception

osgi> java.lang.ClassNotFoundException: com.sap.db.jdbc.Driver at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at employeedetails.EmployeeDataServlet.doGet(EmployeeDataServlet.java:31) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at com.sap.core.jpaas.security.auth.service.lib.AbstractAuthenticator.invoke(AbstractAuthenticator.java:170) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at com.sap.core.tenant.valve.TenantValidationValve.invokeNextValve(TenantValidationValve.java:178) at com.sap.core.tenant.valve.TenantValidationValve.invoke(TenantValidationValve.java:92) at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:53) at com.sap.core.js.monitoring.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:27) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

can anyone help me out on this.

Thanks & Regards,

Akshay Reddy

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Rolf Paulsen Oct 19, 2017 at 07:42 PM
0

Hi, You must have ngdbc.jar in your class path. Probably have to bundle it.

Regards

Rolf

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 31, 2017 at 05:37 AM
0

Hi Rolf,

i have ngdbc.jar now in my classpath but i'm still facing excption at this line

response.getWriter().append("Served at: ").append(request.getContextPath()); Connection con = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.sap.db.jdbc.Driver"); con = DriverManager.getConnection("jdbc:sap://vsa2136201.nwtrial.od.sap.biz:30015", "UserName=NEO_P1942960682TRIAL_GST", "HDB"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM EMPLOYEE"); while (rs.next()) { PrintWriter out=response.getWriter(); out.println(rs.getString(1) +" | "); out.println(rs.getString(2) +" "); response.getWriter().println(rs.getString(1) +" | "); response.getWriter().println(rs.getString(2) +" "); System.out.print(rs.getString(1) + " | "); System.out.print(rs.getString(2) + " "); } rs.close(); stmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); }

com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: Cannot connect to jdbc:sap://vsa2136201.nwtrial.od.sap.biz:30015 [Unknown host vsa2136201.nwtrial.od.sap.biz:30015 [vsa2136201.nwtrial.od.sap.biz], -709].

i had tired in many other ways like whatever host name database name sid instance number which had given in trial account but also m not able to establish the connection. could you please help me out in this.

"jdbc:sap://p1942960682trial.hanatrial.ondemand.com:30015?reconnect=true&timeout=0", " ",

even i tried like this also.

Thanks & Regards,

Akshay Reddy

Share
10 |10000 characters needed characters left characters exceeded