0

Hi,
Im writin the followin code to connect with oracle database.im also using toad .I keep geetin errors even if i declare private String AQC1_UID = ""; and so on..

import java.sql.*;

 public class Login {
public static void main(String[] args)
{
    String AQC1_UID = "";
    String AQC1_USER_PWD = "";

   public Login(String AQC1_UID,String AQC1_USER_PWD)
{   this.AQC1_UID=AQC1_UID;
    this.AQC1_USER_PWD=AQC1_USER_PWD;

  }


 /* public void setUsername(String AQC1_UID) {
     this.AQC1_UID=AQC1_UID;
  }

  public void setPassword(String AQC1_USER_PWD) {
     this.AQC1_USER_PWD=AQC1_USER_PWD;
   }
*/

  public boolean  validate(String user,String password) {
  String query="select * from AIP_QM_CONTROL1";
  System.out.println("---------------------"+query);
   String DbUserName="";
   String DbPassword="";
   String finalUser="";
  try {


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


Connection con=DriverManager.getConnection

("jdbc:oracle:thin@10.192.22.17:1521:AIPUAT1");


Statement stat=con.createStatement();


ResultSet rst=stat.executeQuery(query);

while(rst.next())

  {
   DbUserName=rst.getString("AQC1_UID");

   DbPassword=rst.getString("AQC1_USER_PWD");

   if (AQC1_UID.equals(DbUserName) && AQC1_USER_PWD.equals(DbPassword)) {

   break;
     }


   }
 return true;
 }
 catch(Exception e){

 e.printStackTrace();
 return false;
 }
};
}

}

code showin error while executing in cmd prompt...

illegal start of expression ---public Login(String AQC1_UID,String AQC1_USER_PWD)
                                         ^

can you please tell me whats wrong with the code..

Edited by mike_2000_17: Fixed formatting

3
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by Ankita B
0
public static void main(String[] args)
{
    String AQC1_UID = "";
    String AQC1_USER_PWD = "";

    public Login(String AQC1_UID,String AQC1_USER_PWD)
    { 
        this.AQC1_UID=AQC1_UID;
        this.AQC1_USER_PWD=AQC1_USER_PWD;
    }
.....

When indented properly, the error becomes obvious. Do you see it?

I believe you meant to close of main as an empty method, but didn't.

0

thx so much!!!..it wrked..but isnt displayin the query result..perhaps somethin wrong wit connection..

0

Well, what doers the stack trace show?

One thing though,

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin@10.192.22.17:1521:AIPUAT1");

Why are you loading the driver for the JDBC-ODBC Bridge, then using a url for the Oracle JDBC Thin Driver?

0

Well, what doers the stack trace show?

One thing though,

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin@10.192.22.17:1521:AIPUAT1");

Why are you loading the driver for the JDBC-ODBC Bridge, then using a url for the Oracle JDBC Thin Driver?

-------------------------------
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /processlogin.jsp(1,26) jsp.error.attribute.noequal
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:417)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:126)
at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:169)
at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:136)
at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:149)
at org.apache.jasper.compiler.ParserController.figureOutJspDocument(ParserController.java:254)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:173)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:153)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:219)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)

---------------

String jdbcDriver=System.getProperty("jdbc.driver.class");
Class.forName(jdbcDriver);

Connection con=DriverManager.getConnection("jdbc:oracle:thin@10.192.22.17:1521:AIPUAT1","trn1","trn1");

is this not correct?..hw do we do it then?..

0

Your loading the wrong Driver though. Also, look in the logfiles for the web container and get the "real" stacktrace, not the InternalServerError one.

0

Hi,
the problem was not with the code..there was error in ip address of db server..it does not reside on my m/c so..had to use another ip address..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.