Error in connecting to mysql database using jsp

Hi
I've encountered this error:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
while trying to connect to MySQL db.
I've downloaded the driver from www.mysql.com, and set the classpath as: "C:\mm.mysql.jdbc-1.2b;%CLASSPATH%;"
But it juz doesn't seem to work...
Can someone pls help me?

These are my settings in autoexec.bat:
SET PATH=C:\PROGRA~1\ABRIAS~1\ABRIAS~1\PERL\BIN;%PATH%;
SET JAVA_HOME=C:\jdk1.3.1
SET TOMCAT_HOME=C:\Tomcat3.2.3
SET CLASSPATH=C:\mm.mysql.jdbc-1.2b;%CLASSPATH%;
Well, i'm quite new to jsp so i'm not sure what u meant by "In the servlet container's init scripts?". I onli did the settings above and reset my server.
I've tried checking the dir...and yes there's a dir named org.
Any ideas wat can possibly be wrong???

Similar Messages

  • Error connecting to MySQL database using JNDI

    Hi,
    I'm trying to do a simple connection to a MySQL database using the JNDI look-up
    method.
    Have tried this with the PointBase database that came with WebLogic and got it
    to work successfully.
    However got the attached error message when I tried it on MySQL database. I tried
    this with both the WebLogic's driver for MySQL and also the one I downloaded from
    MySQL (com.mysql.jdbc.Driver), and both failed with the same error message.
    Offhand, it doesn't look like the connection pool is failing. Tested it with WebLogic's
    "Test Pool" function and it was alright.
    Also MySQL database is working properly. Test this by doing simple connection
    and retrieval with simple JDBC connections and it works.
    Any ideas what else I can check with regards to this problem?
    Thanks!
    [att1.html]

    Hi Joe,
    Attached is the config.xml for the domain that I'm working with. There are 3 connection
    pools set-up.
    The problematic Connection Pools are "MySQLCP" and "My JDBC Connection Pool"
    Thanks for your help in this!
    Joe Weinstein <[email protected]> wrote:
    show us the pool definition, as it is in the config.xml file.
    thanks
    joe
    Everbright wrote:
    Hi,
    I'm trying to do a simple connection to a MySQL database using theJNDI look-up
    method.
    Have tried this with the PointBase database that came with WebLogicand got it
    to work successfully.
    However got the attached error message when I tried it on MySQL database.I tried
    this with both the WebLogic's driver for MySQL and also the one I downloadedfrom
    MySQL (com.mysql.jdbc.Driver), and both failed with the same errormessage.
    Offhand, it doesn't look like the connection pool is failing. Testedit with WebLogic's
    "Test Pool" function and it was alright.
    Also MySQL database is working properly. Test this by doing simpleconnection
    and retrieval with simple JDBC connections and it works.
    Any ideas what else I can check with regards to this problem?
    Thanks!
    Error 500--Internal Server Error
    java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogic:pool:MyJDBCConnection Pool, props = {enableTwoPhaseCommit=false, jdbcTxDataSource=true,
    connectionPoolID=MyJDBC Connection Pool, dataSourceName=MyJDBC Data
    Source}.
    Nested Exception: java.lang.RuntimeException: Failed to Generate WrapperClass
         at weblogic.utils.wrapper.WrapperFactory.createWrapper(WrapperFactory.java:141)
         at weblogic.jdbc.wrapper.JDBCWrapperFactory.getWrapper(JDBCWrapperFactory.java:73)
         at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:242)
         at weblogic.jdbc.pool.Driver.connect(Driver.java:158)
         at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:444)
         at weblogic.jdbc.jts.Driver.connect(Driver.java:138)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:298)
         at jsp_servlet.__index._jspService(__index.java:142)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
         at weblogic.jdbc.jts.Driver.wrapAndThrowSQLException(Driver.java:395)
         at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:448)
         at weblogic.jdbc.jts.Driver.connect(Driver.java:138)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:298)
         at jsp_servlet.__index._jspService(__index.java:142)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    [config.xml]

  • Connecting to mysql database using DBLOGIN

    I am trying to connect to a mysql database through GG command interface and am unable to get the DBLOGIN to work correctly. Here is what I am getting:-
    mysql world -u root -p<password> (as user OS user mysql- works!)
    GGSCI (rac1) 5> DBLOGIN SOURCEDB world, USERID root, PASSWORD <password>
    2010-11-08 16:29:17 WARNING OGG-00769 MySQL Login failed: . SQL error (2002). Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
    ERROR: Failed to connect to MySQL database engine for HOST localhost, DATABASE world, USER root, PORT 0.
    I am not too familiar with mysql and will appreciate help and also pointer to documents that walk through setting up and testing Golden Gate with mysql.
    Thanks,
    Satish

    hi.
    i have same problem can't connect to mysql using dblogin on ggsci, please helpme
    this my.cnf configuration
    # Example MySQL config file for small systems.
    # This is for a system with little memory (<= 64M) where MySQL is only used
    # from time to time and it's important that the mysqld daemon
    # doesn't use much resources.
    # You can copy this file to
    # /etc/my.cnf to set global options,
    # mysql-data-dir/my.cnf to set server-specific options (in this
    # installation this directory is /var/lib/mysql) or
    # ~/.my.cnf to set user-specific options.
    # In this file, you can use all long options that a program supports.
    # If you want to know which options a program supports, run the program
    # with the "--help" option.
    # The following options will be passed to all MySQL clients
    [client]
    #password     = your_password
    port          = 3306
    socket          = /tmp/mysql.sock
    #socket = /var/run/mysqld/mysqld.sock
    # Here follows entries for some specific programs
    # The MySQL server
    [mysqld]
    port          = 3306
    socket = /tmp/mysql.sock
    #socket          = /var/run/mysqld/mysqld.sock
    skip-locking
    key_buffer_size = 16K
    max_allowed_packet = 1M
    table_open_cache = 4
    sort_buffer_size = 64K
    read_buffer_size = 256K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 128K
    # Don't listen on a TCP/IP port at all. This can be a security enhancement,
    # if all processes that need to connect to mysqld run on the same host.
    # All interaction with mysqld must be made via Unix sockets or named pipes.
    # Note that using this option without enabling named pipes on Windows
    # (using the "enable-named-pipe" option) will render mysqld useless!
    #skip-networking
    server-id     = 1
    # Uncomment the following if you want to log updates
    #log-bin=mysql-bin
    # binary logging format - mixed recommended
    #binlog_format=mixed
    # Uncomment the following if you are using InnoDB tables
    #innodb_data_home_dir = /var/lib/mysql/
    #innodb_data_file_path = ibdata1:10M:autoextend
    #innodb_log_group_home_dir = /var/lib/mysql/
    # You can set .._buffer_pool_size up to 50 - 80 %
    # of RAM but beware of setting memory usage too high
    #innodb_buffer_pool_size = 16M
    #innodb_additional_mem_pool_size = 2M
    # Set .._log_file_size to 25 % of buffer pool size
    #innodb_log_file_size = 5M
    #innodb_log_buffer_size = 8M
    #innodb_flush_log_at_trx_commit = 1
    #innodb_lock_wait_timeout = 50
    [mysqldump]
    quick
    max_allowed_packet = 16M
    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates
    [myisamchk]
    key_buffer_size = 8M
    sort_buffer_size = 8M
    [mysqlhotcopy]
    interactive-timeout

  • Unable to connect to MySQL Database using MX

    I am unable to connect to MySQL database hosted on a remote
    server. I get the following error message:
    "HTTP Error Code 404 File Not Found. Here are some possible
    reason for the problem:
    1) There is no testing server running on the server machine.
    2) The testing server specified for this site does not map to
    the
    http://72.9.255.2/~keyitems/_mmServerScripts/MMHTTPDB.php
    URL. Verify that the URL Prefix maps to the root of the site."
    I have specified a testing server. My url is "
    http://72.9.255.2/~keyitems/........."
    For the URL prefix to the site's root folder, I listed the
    following:
    1.
    http://72.9.255.2/~keyitems/
    this did not work. I got the above error message.
    2.
    http://72.9.255.2/ this did not work
    also. I got the above error message.
    Any input would be great as I do not know where to start !!!
    Thank you

    Hi Ravi
    Glad to hear you solved this. It is very gratifying when one solves it alone, don't you think?
    Best wishes
    Michael

  • Error to connect  to Mysql database

    hi
    I just initial write program with jsp. I alway have problem.
    I will connect Mysql Database. I 'm download JDBC Driver and setting.
    step of using JDBC
    1. Load Driver JDBC (use method forName())
    2. Connection Database (use method method getConnection())
    3. create object statement (use methodcreateStatement())
    after run, I get this error
    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: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:67: unclosed character literal
         String sql="INSERT INTO test VALUES (",' " +name" ', ' " +surname+" ')";
    ^
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:67: unclosed character literal
         String sql="INSERT INTO test VALUES (",' " name" ', ' " surname+" ')";
    ^
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:67: unclosed character literal
         String sql="INSERT INTO test VALUES (",' " +name" ', ' " +surname+" ')";
    ^
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:67: unclosed character literal
         String sql="INSERT INTO test VALUES (",' " name" ', ' " surname+" ')";
    ^
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:67: unclosed string literal
         String sql="INSERT INTO test VALUES (",' " +name" ', ' " +surname+" ')";
    ^
    An error occurred at line: 6 in the jsp file: /test.jsp
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:76: '{' expected
         catch(SQLExeption e2);
    ^
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:110: 'catch' without 'try'
    } catch (Throwable t) {
    ^
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:31: 'try' without 'catch' or 'finally'
    try {
    ^
    C:\tomcat\work\Standalone\localhost\km\test_jsp.java:120: '}' expected
    ^
    9 errors
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    i don't know error mean
    can anyone explain me and send me a sample code for connect MySQL
    Thank you

    The java code in your jsp is not valid java code; the error messages are explaining why.
    For example, this statement is totally managled.
    String sql="INSERT INTO test VALUES (",' " +name" ', ' " +surname+" ')";It should be:
    String sql="INSERT INTO test VALUES (' " +name+" ', ' " +surname+" ')";If you use PreparedStatement instead of Statement, then the SQL gets much much easier to write (and PreparedStatement has other advatages as well).
    Your other compilation problem is impossible to diagnose without the JSP source code; furthermore, it has nothing to do with JDBC, you simply have broken Java code. You need to post that question in a more appropriate forum.

  • Error when connecting to MySQL Database

    I am trying to connect to MySQL and receive an error everytime. I have attempted to talk to Bluehost (who my site is hosted thru) and they said it is not on their end and not something they can help me with. I set up a new MySQL Database with Bluehost and then set up the site through DW and everything went fine. I secured an ftp connection and went on to connect to MySQL. When I enter in my credentials for SQL Database, it returns:
    HTTP Error Code 404:
    Reason 1. No testing server running on the server machine.
    Reason 2. Testing server specified for this site deos not map to the http://my_domain.com/_mmServerScripts/MMHTPDB.php URL. Verify the URL Prefix maps to the site.
    The testing server model I am using is set to PHP MySQL and URL Prefix I am using (my_domain.com) is my website URL. I watched a YouTube video someone suggested elsewhere on how to add MMHTTPDB.php and mysql.php files to _mmServerScripts folder since the folder is empty but unfortunately, those files are not found on my computer. I assume they were supposed to be installed when I installed DW, but they are not here. I have done a general search of the comp and looked in each folder that was installed with DW and sadly, no files that match those names. What can I do? How can I make an SQL connection? Please help. It is greatly appreciated.
    -Sharon

    Your answer can be found somewhere in here http://forum.wampserver.com/read.php?2,83382,88694
    My hosts file (c:\windows\system32\drivers\etc\hosts) looks like
    # Copyright (c) 1993-2009 Microsoft Corp.
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    # For example:
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    # localhost name resolution is handled within DNS itself.
        127.0.0.1       localhost
        ::1             localhost

  • How to store files in mysql database using JSP?

    I'm developing an online recruitment system using JSP in server side. For the users who registers in it, I want them to upload their cv's from the web site so that I can store it in the database..I'm using mysql as the db..
    Can I know how to do it.?..or else is there any better way of doing that?
    Need a quick reply..Tx

    The best way to put data in a database in a JSP is to not do it. Instead, use a Servlet that calls a DataAccessObject. The DAO puts the data in the DB and the servlet gives the data to the DAO. The JSP does nothing but display results.
    Take a google for JSP MVC and DAO. BalusC has a great example of DAO and a JSP that uses one on his blog.

  • How to connect to mysql database using a proxy

    Folks,
    I wrote a program to connect to both webpage and mysql databases. Because my internet has a firewall (proxy) I set up the internet connection like this:
          System.getProperties().put( "proxySet", "true" );
          System.getProperties().put( "proxyHost", proxyHost);
          System.getProperties().put( "proxyPort", proxyPort);
          Authenticator.setDefault(new MyAuthenticator());The http connection works fine. However the mysql database connection gives me an error:
    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection timed out: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection timed out: connect
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at myapplication$LongTask$ActualTask.<init>(app.java:182)
            at myapplication$LongTask$1.construct(app.java:121)
            at myapplication.SwingWorker$2.run(SwingWorker.java:107)
            at java.lang.Thread.run(Unknown Source)
    ** END NESTED EXCEPTION ** What can I do? Do i need to setup a SOCKS Proxies or something?
    Thanks a lot!!

    SOCKS it is.

  • Java == error while connecting to mysql database?!?!??!

    Hi. I'm using Eclipse to develope jsp pages. I'm new to java.
    I'm trying to connect from a jsp page to mysql server and i'm getting an error on the line below:
    Class.forName("com.mysql.jdbc.Driver");
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    i downloaded the mysql jar file and i added it to my library folder.
    the other question is that is there anyway to mention the name of the database in my connection?
    conn =DriverManager.getConnection("jdbc:mysql://localhost","admin", "");

    hi this is the root cause i thought it might help
    root cause
    javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:100)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
         java.lang.ClassLoader.loadClassInternal(Unknown Source)
         java.lang.Class.forName0(Native Method)
         java.lang.Class.forName(Unknown Source)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:85)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • Urgent, Please help !!! Input Date field in Mysql database using JSP

    Hi All,
    Please help me ! I am trying to store a date field in MySql databaseusing JSP on Tomcat Server.I am gettting the following error.
    I am taking the String Input and then trying to convert it into date type
    inorder to store it into date field in a database.
    I am using the following code :
    <%
    try{
    String dt=request.getParameter("avldt");
    SimpleDateFormat adt= new SimpleDateFormat("dd-MM-yyyy");
    Date sqlToday = new java.sql.Date(adt.parse(dt).getTime());
    catch(ParseException e){
         e.printStackTrace();
    %>
    But I am getting the following error message :
    Class jsp.myjsp.SimpleDateFormat not found.
    Please help me !!!.It's very urgent.
    Thanks,
    Savdeep

    programming is more then copy pasting, it actually is usefull to think about what you are doing. First you declare that you date is format dd-MM-yyyy, then you want to parse a date in format dd/MM/yyyy and behold Java warns you it cannot parse the one into the second ! Cant you solve the rest of this puzzle yourself then ?

  • Populating my dropdown menu from MySQL database using jsp

    I my database i have a table of users and i want everytime a user is added the dropdown menu gets updated, this is make updating of user's profile easy. I tried the one bellow but still get me 80 errors:
    ----connection String------
    <select name="userName" id="userName">
    <% for(int i=1; i<=resultsList; ++i){%>
    <option value="<%=out.println(rs.getUserName(1))%>"><%=out.println(rs.getUserName(1))%></option>
    <option value="<%=out.println(rs.getUserName(i))%>"><%=out.println(rs.getUserName(i))%></option>
    <%}%>
    </select>
    Pls i need help

    80 errors, you say?
    I'm not a fan of writing muddled jsp pages that refer to the database layer. If you're willing to learn JSF or some other web framework, you'll being able to write better code and never use a scriptlet again.

  • Accesing the mysql database using jsp

    hi. I'm trbing to access the mysal data base using the following jsp code. but it gives me the exception: Exception is: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    please help.
    <%@ page language="java" import="java.sql.*" %>
    <%
         String JDBC_DRIVER = ("com.mysql.jdbc.Driver");
         String DATABASE_URI = ("jdbc:mysql://localhost/MCQTest?user=root&password=vishanka" );
         Connection con=null;
         ResultSet rst=null;
         Statement stmt=null;
         int noOfQuestions = 30;
         String [] question = new String [noOfQuestions];
         try
              Class.forName(JDBC_DRIVER).newInstance();
              con=DriverManager.getConnection(DATABASE_URI);
              stmt=con.createStatement();
              rst = stmt.executeQuery("select question from question");
              while(rst.next())
                   for(int i = 1; i<=noOfQuestions; i++)
                        question[i-1] = rst.getString(i);
                        out.print(question[i-1]);
              rst.close();
              stmt.close();
              con.close();
         catch(Exception ex)
              {out.println("Exception is: " + ex.toString());ex.printStackTrace();}
    %>
    <html>
    <head><title>StudentRegistration Front</title></head>
    <jsp:useBean id="user" class="beans.User" scope="session" />
    <body>
    <font color="blue">
    <h2 align="center">
    <p>Welcome <jsp:getProperty name="user" property="name" />:
    </h2>
    </font>
    <form action="marking.jsp" method="post">
    <h4 align="center">
    <input type="submit" value="submit">
    </h4>
    </form>
    </font>
    </body>
    </html>

    sorry guys. the code is given below clearly.
    <%@ page language="java" import="java.sql.*" %>
    <%
         String JDBC_DRIVER = ("com.mysql.jdbc.Driver");
         String DATABASE_URI = ("jdbc:mysql://localhost/MCQTest?user=root&password=vishanka" );
         Connection con=null;
         ResultSet rst=null;
         Statement stmt=null;
         int noOfQuestions = 30;
         String [] question = new String [noOfQuestions];
         try
              Class.forName(JDBC_DRIVER).newInstance();
              con=DriverManager.getConnection(DATABASE_URI);
              stmt=con.createStatement();
              rst = stmt.executeQuery("select question from question");
              while(rst.next())
                   for(int i = 1; i<=noOfQuestions; i++)
                        question[i-1] = rst.getString(i);
                        out.print(question[i-1]);
              rst.close();
              stmt.close();
              con.close();
         catch(Exception ex)
              {out.println("Exception is: " + ex.toString());ex.printStackTrace();}
    %>
    <html>
    <head><title>StudentRegistration Front</title></head>
    <jsp:useBean id="user" class="beans.User" scope="session" />
    <body>
      <font color="blue">
      <h2 align="center">
        <p>Welcome <jsp:getProperty name="user" property="name" />:
      </h2>
      </font>
      <form action="marking.jsp" method="post">
         <h4 align="center">
             <input type="submit" value="submit">
        </h4>
      </form>
      </font>
    </body>
    </html>

  • How to verify if user already exists in MySQL database using JSP?

    Hi, I am trying to create a website that allows users to register and then login. All regsitration details are stored in a MySQL table and I am attempting to have a java bean check that a new user does not already exist by looking up the username. However, I cannot get this to work, the bean is allowing anyone through. I believe there may be a problem with my while loop as the bean checks through the stored usernames in the database. Any suggestions appreciated thanks. See my code below:[
    code]package foo;
    import java.sql.*;
    import java.util.*;
    public class FormBean {
         private String firstName;
         private String lastName;
         private String email;
         private String userName;
         private String password1;
         private String password2;
         private Hashtable errors;
         public boolean validate() {
              boolean allOk=true;
              if (firstName.equals("")) {
                   errors.put("firstName","Please enter your first name");
                   firstName="";
                   allOk=false;
              if (lastName.equals("")) {
                   errors.put("lastName","Please enter your last name");
                   lastName="";
                   allOk=false;
              if (email.equals("") || (email.indexOf('@') == -1)) {
                   errors.put("email","Please enter a valid email address");
                   email="";
                   allOk=false;
              if (userName.equals("")) {
                   errors.put("userName","Please enter a username");
                   userName="";
                   allOk=false;
    try {
              String database = "******hidden******";
              Class.forName("com.mysql.jdbc.Driver");
              Connection conn = DriverManager.getConnection(database,"********hidden*******");
              Statement stat = conn.createStatement();
              String query="SELECT u_name FROM users;";
              String DbUserName="";
              ResultSet rst=stat.executeQuery(query);
              while(rst.next()) {
    DbUserName=rst.getString("u_name");
    if (userName.equals(DbUserName)) {
    allOk=false;
    errors.put("userName","User name already exists, please choose another");
    userName="";
    conn.close();
    break;
    } catch (Exception ex) {
    ex.printStackTrace();
              if (password1.equals("") ) {
                   errors.put("password1","Please enter a valid password");
                   password1="";
                   allOk=false;
              if (!password1.equals("") && (password2.equals("") || !password1.equals(password2))) {
                   errors.put("password2","Please confirm your password");
                   password2="";
                   allOk=false;
    return allOk;
         public String getErrorMsg(String s) {
              String errorMsg =(String)errors.get(s.trim());
         return (errorMsg == null) ? "":errorMsg;
         public FormBean() {
         firstName="";
         lastName="";
         email="";
    userName="";
         password1="";
         password2="";
         errors = new Hashtable();
         public String getFirstName() {
              return firstName;
         public String getLastName() {
              return lastName;
         public String getEmail() {
              return email;
         public String getUserName() {
              return userName;
         public String getPassword1() {
              return password1;
         public String getPassword2() {
              return password2;
         public void setFirstName(String fname) {
              firstName =fname;
         public void setLastName(String lname) {
              lastName =lname;
         public void setEmail(String eml) {
              email=eml;
         public void setUserName(String u) {
              userName=u;
         public void setPassword1(String p1) {
              password1=p1;
         public void setPassword2(String p2) {
              password2=p2;
         public void setErrors(String key, String msg) {     
              errors.put(key,msg);

    Hmm, tried that and now have more build errors in the finally section.
    init:
    deps-jar:
    Compiling 1 source file to C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\build\classes
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:57: cannot resolve symbol
    symbol  : variable rst
    location: class foo.FormBean
                if (rst != null) rst.close();
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:57: cannot resolve symbol
    symbol  : variable rst
    location: class foo.FormBean
                if (rst != null) rst.close();
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:58: cannot resolve symbol
    symbol  : variable stat
    location: class foo.FormBean
                if (stat != null) stat.close();
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:58: cannot resolve symbol
    symbol  : variable stat
    location: class foo.FormBean
                if (stat != null) stat.close();
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:59: cannot resolve symbol
    symbol  : variable conn
    location: class foo.FormBean
                if (conn != null)  conn.close();
    C:\resin-2.1.11\doc\examples\basic\WEB-INF\classes\JavaLibrary1\test\FormBean.java:59: cannot resolve symbol
    symbol  : variable conn
    location: class foo.FormBean
                if (con != null)  conn.close();
    6 errors
    BUILD FAILED (total time: 1 second)Just for a quick test, I deleted the sql exception and finally code and replaced it with a regular exception just to see what happened and got no build errors, however when I run the form I am getting an sql exception from the prepared statement, parameter out of range (1 > 0). I tried reading into prepared statements, and although I now understand their basics, I still have no idea why I'm getting this error?

  • I can't connect to MySQL database from The JSP Standard Tag Library

    Hi All !
    I have a problem, please help me anybody !
    I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
    I have in folder�WEB-INF/lib� following files:
    antlr.jar
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-fileupload.jar
    commons-logging.jar
    commons-validator.jar
    jakarta-oro.jar
    jsf-api.jar
    jsf-impl.jar
    jstl.jar
    mysql-connector-java-3.1.13-bin.jar
    standard.jar
    struts.jar
    I'm using:
    NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
    Ent.Pack 20061020 Visual Wb Pack 061103
    OS WinXP SP2
    Java 1.5.0_10
    MySQL 5.0.18-nt
    1:<%@page contentType="text/html"%>
    2:<%@page pageEncoding="UTF-8"%>
    8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
    10:
    11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    12: "http://www.w3.org/TR/html4/loose.dtd">
    13:
    14: <sql:setDataSource var="ds"
    15: driver="com.mysql.jdbc.Driver"
    16: url="jdbc:mysql://localhost:3306/test"
    17: user="root"
    18: password="xxxx"/>
    19:
    20:
    21:<sql:query sql="select name, age from People" var="res"
    22: dataSource="${ds}"/>
    I have received report on mistake when entered code at the top:
    �/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
    I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
    After build and run I have received
    =========================================START=================================
    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: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
    org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    =======================================END================================
    Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
    BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
    I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
    I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
    There is idea how can resolve this problem
    Thank you in advance ;)

    For all how have similar problem.
    Decision instead of these ways
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    it is necessary to indicate these
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

  • Error while connecting to the database from a JSP Page

    Hi,
    I am using a simple JSP page which is based on the sample JSP pages from OTN.
    When I try to connect to my database using the following code:
    InitialContext ic = new InitialContext();
    OracleDataSource ds = (OracleDataSource)ic.lookup("jdbc/OTN9iDS");
    m_connection = ds.getConnection();
    I get the following error:
    Naming exception Error while connecting to the database : javax.naming.NameNotFoundException: jdbc/OTN9iDS not found in JDBCTest-JDBCTestProject-webapp
    Does anybody know wht this is happening?
    Any help would be appreciated
    FRank

    Hi Frank,
    Are you using standalone OC4J or 9iAS ? If you are using standalone OC4J then you need to add a proper data source entry in %OC4J_HOME%j2ee\home\config\data-sources.xml file.
    If you are using 9iAS the you can log in to the Enterprise Manager console and add the data source entry by using wizard provided by 9iAS.
    Ensure the case of the JNDI lookup string, since, it is case sensitive.
    Hope this helps.
    Abhijeet

Maybe you are looking for