JSP contacting mysql

Im currently using this:
Class.forName("com.mysql.jdbc.Driver"); //which is the mysql-connector-java-3.0.0-beta
connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/xyzDataSournce","abc","xyz");
in my source code, but my jsp doesn't seem to be contacting the xyzDatasource.
I open up winmysqladmin and discover that the driver and setup is using C:\WINNT\System32\myodbc.dll
I've also placed the mysql-connector-java-3.0.0-beta-bin.jar file in
C:\jakarta-tomcat-4.1.10-LE-jdk14\webapps\Alumni\WEB-INF\lib
and added to the class path of the system variable:
C:\jakarta-tomcat-4.1.10-LE-jdk14\webapps\Alumni\WEB-INF\lib\mysql-connector-java-3.0.0-beta-bin.jar
wat am i doing wrong?????

What is the error?

Similar Messages

  • JSP contacting MySQL database

    I want to make a simple Login page that queries a MySQL database. Can someone please tell me if they know of documentation that can take me through easily?

    Connection to any database is alike. Only the database drivers differs. If I am not wrong, this is the string to get connected to MySql database.
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://200.200.200.200/xxxxxx","xxxxxx","xxxxx");
    where first xxxx is the dsn name, and the second xxxx is the userid and the third xxxx is the password to get connected to the mysql database.
    Hope it helps
    Uma
    http://www.javagalaxy.com

  • How to combinate JSP+Tomcat+mysql??

    Hi,guys. My question is as the above subject.
    I have installed JDK, Tomcat, mysql, and my OS is WinXP, I am trying to develop a JSP site in my computer.
    For JDK, the commands javac, java, ...... work OK;
    For Tomcat, http://localhost:8080 works OK, meaning the cat page appears.
    For mysql, I can login, and sql statements work OK;
    And I download mysql-connector-java-3.1.8a.
    What I should do further to combinate JSP+Tomcat+mysql, so my JSP site can work? Any advice?
    I need help.
    Thanks in advance!

    Thanks,duffymo!
    As you said, I am learning more about those things.
    Actually I am trying to open a JSP webpage to show the connection JSP+Tomcat+mysql works OK.
    I copied the mysql-connector-java-3.1.8-bin.jar to ...Tomcat 5.0\common\lib,
    created a datebase, named test in MySQL, and wrote a JSP as the below:
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page language="java" %>
    <%@ page import="com.mysql.jdbc.Driver" %>
    <%@ page import="java.sql.*" %>
    <%
    //driver
    String driverName="com.mysql.jdbc.Driver";
    //username
    String userName="test";
    //code
    String userPasswd="123";
    //database
    String dbName="test";
    //table name
    String tableName="mytab";
    //connection string
    String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection connection=DriverManager.getConnection(url);
    Statement statement = connection.createStatement();
    String sql="SELECT * FROM "+tableName;
    ResultSet rs = statement.executeQuery(sql);
    ResultSetMetaData rmeta = rs.getMetaData();
    int numColumns=rmeta.getColumnCount();
    // output
    out.print("id");
    out.print("|");
    out.print("num");
    out.print("<br>");
    while(rs.next()) {
    out.print(rs.getString(1)+" ");
    out.print("|");
    out.print(rs.getString(2));
    out.print("<br>");
    out.print("<br>");
    out.print("successful!");
    rs.close();
    statement.close();
    connection.close();
    %>
    How can I test the connection JSP+Tomcat+mysql works OK?
    Thanks again!

  • JSP and MySql Connectivity in Fedora core 4

    Dear all,
    We are developing software using JSP and MySql on Fedora Core 4 platform and are unable to find the connectivity for JSP and MySql. Can anybody help....

    Dear all,
    We are developing software using JSP and MySql on Fedora Core 4 platform and are unable to find the connectivity for JSP and MySql. Can anybody help....

  • JSP with MYSQL 4.0

    May i know is JSP works well with MYSQL 4.0 database?

    Yaah..it works perfectly OK....just download the required driver my mysql site only & ur ready to develop applications is JSP using mysql.

  • Unable to connect JSP and MySQL

    Hi, I am new to this forum
    I've started developing web pages using JSP
    I've the problem connecting JSP and MySQL database. I've created the page that retrive records from mysql table. But the connection fail to access to database it gives me this error:
    org.apache.jasper.JasperException: Exception in JSP: /retreive_book.jsp:15
    The code is:
    12: <%
    13: //Class.forName("com.mysql.jdbc.Driver").newInstance();
    14: Class.forName("org.gjt.mm.mysql.Driver");
    15: connection = DriverManager.getConnection(connectionURL,"","");
    16: statement = connection.createStatement();
    17: rs = statement.executeQuery("SELECT * FROM books_detail");
    18: %>
    And the connectionURL parameter has this value:
    String connectionURL = "jdbc:mysql://localhost:3306/books?username=;password=";
    root cause msg is:
    java.sql.SQLException: Invalid authorization specification: Access denied for user 'nobody'@'localhost' (using password: NO)
    Please can anyone help me. It is 3 days now trying to do that but not succeded yet

    Hi
    Yes It is true that my MySQl installation its username is root. So how should put that in the url. Cause I did that but it didn.t work
    String connectionURL= "jdbc:mysql://localhost:3306/books?username=root;password=";
    If I write in that manner is it correct for root username or should I put a single quote
    Thanks

  • How to create table with jsp in mysql

    Hi, every one,
    I just want to know how to create a table with jsp in mysql, please.
    Thanks in advance

    I have got the same question. I tried to pass sql "Create table" statement, but the servlet engine (tomcat4) threw an error "could not manipulet statement.execute". It works for normal SQL select statement.
    Anyone got the same problem ? or got a solution for this ? someone told me that PHP can do it, but just want to get it works with JSP.

  • PleaseHelp on jsp and Mysql connectivity and a lot of exception errors

    Hi,
    I am Trying to connect a JSP page with Mysql database. I am having a lot of probelms. After having a lot of problems in connecting the JSp with Mysql. Intilally it was giving me the exception error that " NO appropriate driver was found. After modifying the URl it was fine. Now It is giving the Following errors.
    servlet.ServletException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream
    In a window before loading the Explorer page it is giving the following error that The port 8081 is already in use and i should expand to other ports. Noraml JSP Files which used to work before are also not working .
    Internal Tomcat JWSDP is alos not working. If i try to start the server it says that port 8081 is already in USe . A java.net.connection exception is also occuring. The normal JSP files are also not working. What is Happening. I am also giving the code i have writted. PLease tellme why so many exception errors are occuring.
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8081/mis_project", "root", " ");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select study_semester FROM Semester");
    while(rs.next()) {
    %>
    <option value="<%= rs.getString("Study_Semester") %>">
    </option>
    <% }
    if(rs!=null) rs.close();
    if(stmt!=null) stmt.close();
    if(con!=null) con.close();
    I am trying to connect to Mysql and automatocally populate a field in a Form in later JSp pages i intend to record the data entered in these fields into other tables.

    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/myDB?user=username&password=mypass");
    Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
    String cat = "";
              try{
              cat = request.getParameter("category");
              }catch(NullPointerException npe){}
              ResultSet rs = stmt.executeQuery("SELECT id,fullname FROM users WHERE category LIKE '%motor%' AND subcategory like '%"+cat+"%'");
         %>
    This piece gets a category parameter from a form post and uses it to search for a specific category in a database table. I think maybe u need to download JConnector from mysql site and unzip it to the classes folder of your WEB-INF in Tomcat server...... i hope this helps a bit

  • Dependant lovs in jsp with mysql data

    hi to all.
    here is my doubt
    How to create dependant dynamic list of values in jsp where the data comes from mysql tables.(I mean i am storing all the details in mysql tables using foreign keys etc..).
    Ex.:country--->state--->district--->city--->
    we will be having this in most of the sites in general.
    Hope u got what i am looking for
    Expecting a very quick and excellent answer.
    thank you

    Within jsp pages it is not possible to have the comboboxes dynamically updated without intervention to either refresh the page with the new data or use java script.
    I had a similar problem which i resolved with java script :
    Interactive combo boxes on jsp
    Have a look at this thread for more info.

  • JSP + JDBC + MySql Problem (Tomcat 4.1)

    I'm completely helpless... whenever I try to retrieve stuff from the db (using a jsp page), I get errors that don't even make sense.
    out.println(stmt.executeQuery("SELECT * FROM newsTbl WHERE articleID = 1").getString("articleTitle"));if I try doing the above, I get a "ServletException : Before start of result set" error that supposedly occurred at this line of the generated servlet:
    if (pageContext != null) pageContext.handlePageException(t);---------------
    If i try this:
    ResultSet rsSec = stmt.executeQuery("SELECT * FROM newsSecTbl");
    rsSec.beforeFirst();  //<-- Even if I don't have this line the result does not change
      out.println(rsSec.next());
      while (rsSec.next()) { ... }I the while loop is never initiated, because rsSec.next() is false... kind of weird if you ask me, I even put two entries into the table to make sure the cursor wasnt at the first record and saying there was no second one (which would have been right if there were only one record).
    I would be very grateful if someone could help me out with this. I've never done any db programming with Java yet, so I dont have a clue what Im doing. By the way, I'm using MySql (indicated in the title) and the server was running and available when I ran the above code.
    Cheers,
    Tom

    You can't do this:
    out.println(stmt.executeQuery("SELECT * FROM newsTbl WHERE articleID = 1").getString("articleTitle"));The ResultSet you get back is a database cursor that doesn't point to the first row yet. The correct idiom is:
    String sql = "SELECT * FROM newsTbl WHERE articleID = 1";
    ResultSet result = stmt.executeQuery(sql);
    String articleTitle = "";
    while (result.next())
       title = result.getString("articleTitle");
    result.close();
    stmt.close();If you've never done DB programming before, I'd recommend that you click on the Tutorials link to the left and go through the JDBC tutorial carefully. You'll save yourself a lot of grief.
    Another good idea would be to separate out all your database code into at least one separate object, independent of the servlet. That way you can test and develop it off to the side until it's 100% solid. Then your servlet can simply instantiate one and use it. All your problems from that point forward will be servlet issues, because you'll know that your database code is working. - MOD
    See if that works better. - MOD

  • JSP/Tomcat/MySQL

    Hello JSP developers!
    I have a problem trying to connect to MySQL database when I am doing a JSP or a servlet. I think the problem has to be with Tomcat, because when I do a java application with a database connection works perfectly, so there must be Tomcat.
    I am working with Java j2sdk1.4.0 and Netbean as my IDE. When I compile the JSP under the IDE does not give me any errors but when I try to see the result with Tomcat 4.0 does not seem to recognize the mm.mysql driver and gives me the following errors:
    Generated servlet error:
    D:\Apache Tomcat 4.0\work\localhost\_\JspMySQL$jsp.java:75: Class org.apache.jsp.Connection not found.
    Generated servlet error:
    D:\Apache Tomcat 4.0\work\localhost\_\JspMySQL$jsp.java:76: Class org.apache.jsp.ResultSet not found.
         ResultSet results;
    It gives me more errors, related to the connection. If you are willing to help me I can send you the exception report that Tomcat generates.
    I would really appreciate if you help me about this issue, because I am beginnig to get frustated.
    Thanks!!!!

    It appears that your JspMySQL.jsp does not import the java.sql package. Try adding the following line at the top of the JSP:
    <%@ page import="java.sql.*" %>

  • JSP with MySQL connection in Tomcat6.0.20

    Hi i'm using MySQL5.1, Tomcat6.0.20 in my project, There i'm not able to connect to the database. it's giving the error.
    My program is :
    <%@ page language="java" import="java.sql.*" %>
    <%
         String driver = "org.gjt.mm.mysql.Driver";
         Class.forName(driver).newInstance();
         try{
              String url="jdbc:mysql://localhost/books?user=root@localhost&password=india123";
              Connection con=DriverManager.getConnection(url);
              Statement stmt=con.createStatement();
         catch(Exception e){
              System.out.println(e.getMessage());
         if(request.getParameter("action") != null){
              String bookname=request.getParameter("book_name");
              String author=request.getParameter("author");
              stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
              ResultSet rst=stmt.executeQuery("select * from books_lib");
              %>
              <html>
              <body>
              <center>
                   <h2>Books List</h2>
                   <table border="1" cellspacing="0" cellpadding="0">
                   <tr>
                        <td><b>S.No</b></td>
                        <td><b>Book Name</b></td>
                        <td><b>Author</.b></td>
                   </tr>
                        <%
                        int no=1;
                        while(rst.next()){
                        %>
                        <tr>
                        <td><%=no%></td>
                        <td><%=rst.getString("book_name")%></td>
                        <td> <%=rst.getString("author")%> </td>
                        </tr>
                        <%
                        no++;
         rst.close();
         stmt.close();
         con.close();
    %>
                   </table>
                   </center>
              </body>
         </html>
    <%}else{%>
         <html>
         <head>
              <title>Book Entry FormDocument</title>
              <script language="javascript">
              function validate(objForm){
                   if(objForm.bookname.value.length==0){
                   alert("Please enter Book Name!");
                   objForm.bookname.focus();
                   return false;
                   if(objForm.author.value.length==0){
                   alert("Please enter Author name!");
                   objForm.author.focus();
                   return false;
                   return true;
                   </script>
              </head>
              <body>
                   <center>
    <form action="BookEntryForm.jsp" method="post" name="entry" onSubmit="return validate(this)">
         <input type="hidden" value="list" name="action">
         <table border="1" cellpadding="0" cellspacing="0">
         <tr>
              <td>
                   <table>
                        <tr>
                        <td colspan="2" align="center">
    <h2>Book Entry Form</h2></td>
                        </tr>
                        <tr>
                        <td colspan="2"> </td>
                        </tr>
                        <tr>
                        <td>Book Name:</td>
                        <td><input name="bookname" type="text" size="50"></td>
                        </tr>
                        <tr>
                        <td>Author:</td><td><input name="author" type="text" size="50"></td>
                        </tr>
                        <tr>
                             <td colspan="2" align="center">
    <input type="submit" value="Submit"></td>
                             </tr>
                        </table>
                   </td>
              </tr>
         </table>     
    </form>
                   </center>
              </body>
         </html>
    <%}%>
    The error page is:
    HTTP Status 500
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 19 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    16:      if(request.getParameter("action") != null){
    17:           String bookname=request.getParameter("book_name");
    18:           String author=request.getParameter("author");
    19:           stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
    20:           ResultSet rst=stmt.executeQuery("select * from books_lib");
    21:           %>
    22:           <html>
    An error occurred at line: 20 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    17:           String bookname=request.getParameter("book_name");
    18:           String author=request.getParameter("author");
    19:           stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
    20:           ResultSet rst=stmt.executeQuery("select * from books_lib");
    21:           %>
    22:           <html>
    23:           <body>
    An error occurred at line: 45 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    42:                     no++;
    43:      }
    44:      rst.close();
    45:      stmt.close();
    46:      con.close();
    47: %>
    48:                </table>
    An error occurred at line: 46 in the jsp file: /singleupload/BookEntryForm.jsp
    con cannot be resolved
    43:      }
    44:      rst.close();
    45:      stmt.close();
    46:      con.close();
    47: %>
    48:                </table>
    49:                </center>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    Please help me

    ?An error occurred at line: 20 in the jsp file: /singleupload/BookEntryForm.jsp stmt cannot be resolved
    That means it can't see any variable declared called "stmt"
    There isn't one at this point.
    The stmt variable you have declared up above, is nested in curly braces - within your try/catch statement. As such it only has scope within those curly braces. If you want to use stmt outside of the try block, you need to declare stmt outside of it.
    And yes, I echo Balusc's comments about scriptlet code in a jsp page.
    A better solution would be to write a java class with a method that does the database query, and returns a List of objects.
    Your JSP can then take that list of objects and display them on the page.
    Its a bit more work, but makes the code much easier to write/maintain/test because you separate out the "data" and "view" layers.

  • How to connect JSP with MySql Database?

    HI All...
    I want to know or How to connect Mysql with JSP or JSF any other software is available? please help me.....

    I want to know or How to connect Mysql
    with JSP or JSF any other software isavailable?
    please help me.....First you need to find 25 m of a CatV cable and...The DB files need to be located on the ninth device of a SCSI Daisy Chain with the total SCSI cable length being over 150 m (and the devices (and cables) need to be mix of Differential and Non-Differential).
    Edit: And forget the terminator, who needs it?

  • Syntac error in JSP and MySQL

    HI guys,
    I have been facing another problem. The codings below. Worked well with my JSP and Access database.
    Then I transfered my database to MySQL and it gives out syntax error in my SQL statement.
    CODE1:
         sql = "SELECT Week, SUM (Total_Inspected) AS ins, SUM (Total_Rejected) AS rej, SUM (Total_Accepted) AS acc, SUM (DPPM) AS dpp, SUM (Yield) AS yeel FROM Calc_Data WHERE MONTH(Inspect_Date) ="+bulann+" GROUP BY Week";
         ResultSet rs = stm.executeQuery(sql);
    CODE2:
    String query   = "SELECT ID, Model, Lot_No, Lot_Qty, Inspected_By, Reject_Desc, Area_Concerned, Location, Remark FROM OQA WHERE Customer = '"+customer+"' AND Inspect_Date =#"+tarikh+"#";
    ResultSet rs   = stmt.executeQuery(query);

    Whenever you have this type of problem, the easiest
    solution is to take the sql and try running it
    directly. For MySQL, you can either use the
    command-line client, or there are a few graphical
    clients that can handle it. Just type in the query,
    run it, and let the database itself tell you what the
    error is.
    In any case, you probably won't find much useful
    advice on a JSP forum, esp. since the problem has
    absolutely nothing to do with JSP.Indeed - I agree with this. - MOD

  • JSP with MYSQL.

    Dear Friends
    I have a unique problem in java, when i try to connect to mysql db.
    It shows an error message:
    Unable to load driver. Getting Connection ... SQLException: No suitable driverI am using mysql MySQL 4.1.9 and tomcat 5.5 version.
    though i have loaded the driver in lib directory, it still displays the same error
    messgae. Here is the jsp file which i use to connect to my database.
    http://localhost:8080/mysqljdbc.jsp
    <%@ page import="java.net.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.sql.*" %>
    <%
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         catch (Exception E) {
         out.println("Unable to load driver.");
         E.printStackTrace();
         try{
              out.println("Getting Connection ...");
              Connection C = DriverManager.getConnection("jdbc:mysql://localhost:3306/vinoth");
              out.println("<br>Connected:  " + !C.isClosed() + "<br>\n");
              out.println("Catalog:  " + C.getCatalog() + "<br>\n");
                   Statement S = C.createStatement();
                   ResultSet rs = S.executeQuery("SELECT * FROM foo");
                   ResultSetMetaData rsStruc = rs.getMetaData();
                   out.println("Table:  " + rsStruc.getTableName(1) + "<br>");
                   out.println("<table bgcolor=c8c8c8 cellpadding=5 cellspacing=1>");
                   out.println("<tr bgcolor=000000>");
                   int colCount = rsStruc.getColumnCount();
                   String colName = "";
                   for(int i=1;i <= colCount; i++){
                   colName = rsStruc.getColumnName(i) ;
                   out.println("<td><B><font color=white>" + colName + "</font></b></td>\n");
                   out.println("</tr>");
                   while (rs.next()) {
                   out.println("<tr bgcolor=ffffff>");
                   for(int i=1;i <= colCount; i++){
                   colName = rsStruc.getColumnName(i) ;
                   String fld = rs.getString(colName);
                        out.println("<td>" + fld + "</td>");
                   out.println("</tr>");
                   out.println("</table>");
                   rs.close();
                   C.close();
         catch (Exception E) {
          out.println("SQLException: " + E.getMessage());
    %>Now is there anything i have to configure apart from this.
    Thanx in advance.

    First things first...i definitely recommend you take out the db stuff out of the jsp page. Place the logic in a DAO and if you have to reference the dao in the jsp. Although in a practice you should have a service layer which does the db stuff. Use a servlet to call the service layer and pass the results of the service layer to the jsp.
    Writing java code like that in the jsp is just bad programming. There are loads of web frameworks that enable you to develop scalable web applications.
    I realise that this does not help you but it is a good idea to get the design correct before embarking on the development.

Maybe you are looking for

  • What am I supposed to do with these issues?

    I found this: 2013-11-29 10:49:28 +0100 Encrypted file: /Users//Downloads/AdobeFlashPlayerInstaller_11_ltrosxd_aaa_aih-2.dmg 2013-11-29 10:49:29 +0100 Encrypted file: /Users/Downloads/AdobeFlashPlayerInstaller_11_ltrosxd_aaa_aih.dmg

  • Ip10 - Vendor blocked

    Hi, When trying to schedule the maintenance plan in IP10, it's showing that Vendor is blocked. How it's related to vendor when scheduling it. To my knowledge, whenever it's scheduled, a WO will be created on the scheduled date and that WO will create

  • Store image and document files

    If I define a table column as BLOB type, and I want it to hold image files. Can I used it for holding multiple images/pictures? Same question is asked for the document files such as .DOC or .PDF files? I mean something like this: ROW ID BLOB Row 1 Im

  • How to calculate the number of months between two string as yyyymm

    Dear all, I have two month string like yyyymm e.g. 201003 -- 201105. Now I want to calculate the number of months bertween these two month string? How can I do that? Thanks.

  • To store a file in a field.

    How can I store a file in a table4s field ?