| Author |
connection call
|
Abebe Belew
Greenhorn
Joined: Jul 21, 2004
Posts: 19
|
|
Action ====== package app; import org.apache.struts.action.*; import javax.servlet.http.*; import java.io.*; 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); conn.close(); } } 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.io.*; 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 (rset.next()) { 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
Joined: May 15, 2002
Posts: 116
|
|
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 cheers, parthi
|
Even crazy and silly looking problems are sometimes real.
|
 |
 |
|
|
subject: connection call
|
|
|