on 04-14-2016 7:46 AM
Hi,
I followed this tutorial SAP HANA Cloud Platform and successfully run this application on HCP.
Then, I 'm trying to get data from my backend system via RFC and saving these data on HCP using Persistence With JDBC service.
I have successfully got the data(backend system information). However when I was going to save the date on HCP, there is an exception
My codes is almost the same as SAP HANA Cloud Platform, and there is only few changes. I'm sure that this problem happened when application run in red line, but I don't know why it is different from the tutorial? Can anyone help me to solve this problem?
Best Regard,
Jelly.
Here are my codes:
SystemInfoJDBCServlet:
private SystemInfoDAO sInfoDAO;
public void init() throws ServletException{
try{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DefaultDB");
sInfoDAO = new SystemInfoDAO(ds);
}catch(SQLException e){
throw new ServletException(e);
}catch(NamingException e){
throw new ServletException(e);
}
}
SystemInfoDAO :
public class SystemInfoDAO {
private DataSource dataSource;
public SystemInfoDAO(DataSource newdatasource) throws SQLException{
setDataSource(newdatasource);
}
public void setDataSource(DataSource newdatasource) throws SQLException{
this.dataSource = newdatasource;
checkTable();
}
public DataSource getDataSource(){
return dataSource;
}
public void addSystemInfo(SystemInfo systeminfo) throws SQLException{
Connection connection = dataSource.getConnection();
try{
PreparedStatement pstmt = connection.prepareStatement("INSERT INTO SYSTEMINFOS (INFO) VALUES (?)");
pstmt.setString(1, systeminfo.getInfo());
pstmt.executeUpdate();
}finally{
if(connection != null){
connection.close();}}}
Actually, I feel confused about this line of code:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DefaultDB");
personDAO = new PersonDAO(ds);
What is the DefaultDB?
I didn't create any schema on HCP, but after I run the sample application there is a schema created like this:
Is this schema created by default? And is this schema the Datasource above?
Why when I using this datasource like: systemInfoDAO = newSystemInfo(ds); I faced a HTTP500 error? I mean when I run the sample application, it works. But when I write a new code line, it won't work.
Is there any way can I configure the DataSource?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please go step by step.
Did you already checked the log files as I suggested? You may find this:
2016 04 15 07:12:39#+00#ERROR#com.sap.cloud.sample.persistance.PersistanceWithJDBCServlet##anonymous#http-bio-8041-exec-3#na#i321727trial#jdbc#web#i321727trial#Persistance operation failed
org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed
...
Caused by: com.sap.dbtech.jdbc.exceptions.jdbc40.SQLSyntaxErrorException: [-4005] (at 8): Unknown column name:ID
at com.sap.dbtech.jdbc.exceptions.jdbc40.SQLSyntaxErrorException.createException(SQLSyntaxErrorException.java:53)
at com.sap.dbtech.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:251)
at com.sap.dbtech.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:138)
at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:69)
at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:1096)
at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:720)
at com.sap.dbtech.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1840)
at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:932)
at com.sap.dbtech.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:234)
at com.sap.dbtech.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:187)
at com.sap.dbtech.jdbc.CallableStatementSapDB.(CallableStatementSapDB.java:99)
at com.sap.dbtech.jdbc.CallableStatementSapDBFinalize.(CallableStatementSapDBFinalize.java:11)
at com.sap.dbtech.jdbc.ConnectionSapDB.prepareStatement(ConnectionSapDB.java:976)
at com.sap.dbtech.jdbc.trace.Connection.prepareStatement(Connection.java:413)
at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sap.core.persistence.jdbc.trace.TraceableBase$1.invoke(TraceableBase.java:44)
at com.sun.proxy.$Proxy6.prepareStatement(Unknown Source)
at com.sap.core.persistence.jdbc.trace.TraceableConnection.prepareStatement(TraceableConnection.java:121)
at org.apache.commons.dbcp.PoolingConnection.makeObject(PoolingConnection.java:285)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1216)
at org.apache.commons.dbcp.PoolingConnection.prepareStatement(PoolingConnection.java:107)
... 35 more|
For other question please check
Regards, Xu
Hi Xu,
Sorry for being late to reply you.
Here are my application log files:
2016 04 20 02:05:58#+00#ERROR#com.sap.cloud.sample.persistance.PersistanceWithJDBCServlet##anonymous#http-bio-8041-exec-7#na#i321727trial#jdbc#web#i321727trial#Persistance operation failed
org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed
at org.apache.commons.dbcp.PoolingConnection.prepareStatement(PoolingConnection.java:113)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)
at com.sap.cloud.sample.persistance.PersonDAO.selectInfo(PersonDAO.java:107)
at com.sap.cloud.sample.persistance.PersistanceWithJDBCServlet.getInfo(PersistanceWithJDBCServlet.java:107)
at com.sap.cloud.sample.persistance.PersistanceWithJDBCServlet.doGet(PersistanceWithJDBCServlet.java:64)
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 com.sap.core.communication.server.CertValidatorFilter.doFilter(CertValidatorFilter.java:324)
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:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at com.sap.core.jpaas.security.auth.service.lib.AbstractAuthenticator.invoke(AbstractAuthenticator.java:205)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at com.sap.core.tenant.valve.TenantValidationValve.invokeNextValve(TenantValidationValve.java:168)
at com.sap.core.tenant.valve.TenantValidationValve.invoke(TenantValidationValve.java:92)
at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:24)
at com.sap.core.js.monitoring.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:25)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:812)
Caused by: com.sap.dbtech.jdbc.exceptions.jdbc40.SQLSyntaxErrorException: [-4005] (at 8): Unknown column name:ID
at com.sap.dbtech.jdbc.exceptions.jdbc40.SQLSyntaxErrorException.createException(SQLSyntaxErrorException.java:53)
at com.sap.dbtech.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:251)
at com.sap.dbtech.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:138)
at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:69)
at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:1096)
at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:720)
at com.sap.dbtech.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1840)
at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:932)
at com.sap.dbtech.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:234)
at com.sap.dbtech.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:187)
at com.sap.dbtech.jdbc.CallableStatementSapDB.<init>(CallableStatementSapDB.java:99)
at com.sap.dbtech.jdbc.CallableStatementSapDBFinalize.<init>(CallableStatementSapDBFinalize.java:11)
at com.sap.dbtech.jdbc.ConnectionSapDB.prepareStatement(ConnectionSapDB.java:976)
at com.sap.dbtech.jdbc.trace.Connection.prepareStatement(Connection.java:413)
at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sap.core.persistence.jdbc.trace.TraceableBase$1.invoke(TraceableBase.java:44)
at com.sun.proxy.$Proxy6.prepareStatement(Unknown Source)
at com.sap.core.persistence.jdbc.trace.TraceableConnection.prepareStatement(TraceableConnection.java:121)
at org.apache.commons.dbcp.PoolingConnection.makeObject(PoolingConnection.java:285)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1216)
at org.apache.commons.dbcp.PoolingConnection.prepareStatement(PoolingConnection.java:107)
... 35 more
Honestly speaking, I still feel confused about this log files. So may the SQL statements be the problem?
BR,
Jelly
Hi,
please check the log files of your application to find more details of the cause.
Best regards
Xu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.