File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection call

Abebe Belew
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package app;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.lang.*;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import app.pcSQLException;
import app.db_connection;

public class RegisterAction extends Action{

private String selectstr ;
private String mrn = "";

public ActionForward execute (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)

String mrn = ((RegisterForm) form).getMrn();

javax.sql.DataSource dataSource;
java.sql.Connection conn;

try {
dataSource = getDataSource(request);
conn = dataSource.getConnection();

try {
if(mrn.length() != 0){
selectstr = db_connection.queryExecute(mrn, conn);

} catch (pcSQLException e) {
System.out.println ("Error Executing Query: " + e.getMessage());

} catch (Exception e) {
System.out.println (e.getMessage());

HttpSession session = request.getSession(true);
session.setAttribute("registerSess", selectstr);

return mapping.findForward("success");


my bean:
package app;

import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;

public class db_connection {

public static String queryExecute(String mrn, Connection conn)
throws pcSQLException {

try {
String querytext = null;
String strQuery = "select mrn from qdsn.procedurea where mrn = '" + mrn + "' ";
Statement stmt = conn.createStatement();
System.out.println("conn = " + conn);
ResultSet rset = stmt.executeQuery(strQuery);

while ( {
querytext = rset.getString(1);
System.out.println("this is result from bean" + querytext);
return querytext;
}//end while

} catch (Exception e) {
throw new pcSQLException();
}//end catch
return null;
}//end db_connection

Error Message while trying to compile:

queryExecute() in app.db_connection cannot be applied to (java.lang.String,java.sql.Connection)
[javac] selectstr = db_connection.queryExecute(mrn, conn);
[javac] ^
[javac] 1 error

Please help!!!
Thanx in advance
parthiban subramaniam
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cant see anything worng with the code mate
unless you have a old version of db_connection class which had the method queryExecute()
this should not happen,
clear out the classes and try to recompile thos whole lot from the scratch

hope that helps
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic