Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Fail to run Tutorial Adding Persistence With JDBC (Java Web SDK)

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

HTTP Status 500 - org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed.

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();}}}

Former Member
Not what you were looking for? View more on this topic or Ask a question