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

Similar Messages

  • 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....

  • 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

  • Problems with JSP and MySql bean.

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

  • Unable to connect java to mysql

    I have installed mysql on my linux machine (i didnt modify any default configuration settings, just using the default settings). And in my lan, from another machine in windows from my java code i am trying to connect to mysql of linux, but donno why i get connection refused error. Can someone help me to figure what the steps i am missing or need to do?

    Thanks for your reply. I do not have any network managers. I have installed mysql on my linux machine and also started mysql. Now in remote machine i have downloaded mysql-connector-java-5.0.4-bin.jar file and using this jar file my java code is trying open a connection to mysql.
              try {
                   Class.forName("com.mysql.jdbc.Driver");
              }catch(Exception ce) {ce.printStackTrace();}
              try {
                   Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.20.160:3306/mysql","root","new_password");192.168.20.160 is the linux machine where mysql is running.
    But of no use, i get connection refused error. following is stacktrace
    SQLException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection refused: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection refused: 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(DriverManager.java:525)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at TestDriver.main(TestDriver.java:11)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 63 ms ago.
    SQLState: 08S01
    VendorError: 0

  • 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

  • Unable to connect Forms and Report with Oracle 9i database

    Dear All
    Please help
    I have received the following message when i connect Developer 10G Report builder with oracle 9i database.
    scott/tiger@z
    REP-0501:Unable to connect to the specified database ORA-12154:TNS could not resolve service name.
    I have written the following text in tnsnames.ora file.
    # TNSNAMES.ORA Network Configuration File: E:\ora_10g\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    z =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = zkhan-dfml)(PORT = 1521))
    (CONNECT_DATA =
    (SID = dba)
    One more thing that i need to mention,I have also installed Oracle Report 6i and its connecting well.I have installed Oracle database in my own computer.
    Regards

    [email protected] wrote:
    Thanks for the reply,Now my tnsnames.ora file is look like this.
    z =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = zkhan-dfml)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = dba)
    but still facing the same error ,one more thing that i need to mention, I have 3 Oracle home.details are:
    for Oracle database 9i
    for report builder 6i
    for Developer 10G
    Kindly advise.Yes, you definately needed to mention that. That suggests you also have 3 $ORACLE_HOME/network/admin directories, each with its own tnsnames.ora file. So you need to make sure you are hitting the correct one. I'd pick one to be the controlling one and set the TNS_ADMIN enviornment variable to point to it.

  • Unable to Connect PC and update

    I am using Sony Tablet S. Model SGPT112SG/S. I have few queries as follows.
    1. I am unable to connect the Tablet to PC companion. It shows as "PC companion must be updated". But I am using the latest one.
    2.Android version is 4.0.3 (release5a).  When I check for updates. It shows "The system software is up to date". But I see Jelllybean update has released. How can i update.
    3. Is Timescape is not included in the tablet. I have installed from play store. But still uanble to use it.
    4. Does sony tablet can be charged connecting to PC through USB.
    5. How to reduce the number of slides in the Home screen. It has 5. I want only 3.
    Solved!
    Go to Solution.

    Because jelly bean only came out for xperia tablet s not tablet s1 which you have.
    all you can do is keep nagging at sony to fix your tablet and release jelly bean as software is broken on tablet s1

  • Steps cor connectivity java and mysql

    Hi can any one list the steps for the connectivity of java & mysql.
    jdk1.6 & mysql5

    1) Learn JDBC: http://java.sun.com/docs/books/tutorial/jdbc/index.html
    2) Obtain the MySQL JDBC driver: http://www.mysql.com/products/connector/j/
    3) Read the MySQL JDBC driver reference documentation: http://dev.mysql.com/doc/refman/6.0/en/connector-j-reference.html

  • 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?

  • [INSTALLATION] Connect Xampp and MySQL?

    Hi,
    I want to install MySQL-PHP-Apache.
    The first thing I did was to download and install MySQL.
    Then, I installed Xampp.
    The main reason why I installed MySQL separatly was to be able to use MySQL from a command-line. With the Xampp install, we can't.
    How can I connect the MySQL install and the Xampp install? I mean that if I, for example, create a database in a command-line, involving only MySQL, the changes are not applied to the Xampp (phpMyAdmin).
    I don't know if you understand...
    Maybe should I install PHP and Apache separatly also (without Xampp)?
    Thanks!:)

    http://wiki.archlinux.org/index.php/MySQL <- did you follow this ?

  • JSP and MySQL

    dear all,
    I am new to sql and database programming and am a bit confussed about the line:
    Connection Conn = DriverManager.getConnection("jdbc:mysql:dbname");
    the jdbc is the what is the dbname??? is it the address of the database on your hard drive??? how is it formated??? what is the file that you need to point to??? how dies this work
    Thanks T

    Hi
    the JDBC Url should have the following format
    jdbc:mysql://<hostname>:<port>/<database>
    If your MySQL Database is running at your local host
    and it is using the default port than you can use
    jdbc:mysql://127.0.0.1:3306/test
    jdbc -> Means you are trying to open a jdbc connection
    mysql -> MySQL Databse Driver
    (make sure that your MySQL jdbc driver is registered)
    to connect to the test database on your MySQL Server
    regards
    thsimon

  • HT1918 unable to connect click and buy in iTunes, app store does work

    I try to buy software on my iPhone, this is normal connected to a Click and Buy account.
    The strange thing is that I can use the Click and Buy account in the OS X App store and not in the iTunes store.
    Is it possible that there is an old Click and Buy account still somewhere in the system that does block the option to connect the new one?

    Has it been 24 hours?
    I take it this was a gift card.  iTunes Store:  Invalid, Inactive, or Illegible codes http://support.apple.com/kb/TS1292 - gift cards
    I don't know if this provides an alternative means: https://expresslane.apple.com ; select 'iTunes' in the first column; 'iTunes Store' in the second column
    If you are really desperate you could buy the app yourself, then request reimbursement.

  • About jsp and mysql

    Hi all,
    Requirement:
    I have a front end in which there are 3 fields name,age,status when ever I enter values these should be stored in mysql db.and here in status I have check constraint it should be either 'Active' or 'Inactive'
    when ever I enter Active into status text field It should store as 1 in db
    when ever I enter Inactive into status text field it should store as 0 in db .
    How to acheive this please give me some suggestions
    Thanks in Advance....

    Also, rather than submit the page on clicking the 'save' button, have an onClick() attribute added to the save button that calls a javascript function. In the javascript function, do some basic client side validation before allowing the function to submit to the server. Example: name cannot be empty, age cannot be empty, age must be a number (no letters), either active or inactive must be checked.

  • Unable to Connect WRE54G and WRT54G

    So I've got a WRT54G Router and a WRE54G Range Expander. The router works fine on its own (Firmware 2.02.7) but when I try to get them working together, it just doesn't work. I tried the auto config on the Range Expander, but to no avail. I tried running the Setup Utility from the CD, and once I get past confirming my wireless settings it says that it can't find the Range Expander and to make sure that it's powered on (which it is). My computer IS getting a signal (an excellent one at that) from the range expander as "CNITS," but it doesn't have an internet connection from the router. What do I have to do to make this thing work?

    Well, as you see from the threads on this board, this is a common problem. I experienced practically everything mentioned here, including the IP confict business but I consider myself "Luckydog" because I finally got it to work (after long hours). The settings on your router should be fine if everything was working pre-RE. The RE is just supposed to mimic them.  Unfortunately, there is no simple answer but trial and error. What I would recommend for you right now is reset the RE to default with the pinhole switch and configure the RE with the ethernet cable and IE interface. Don't try the autoconfig or the CD software. Also, power cycling the whole WIFI network system, PCs, router, RE,  printer servers, etc. does wonders. Bring the router up first as that should start assigning the IP addresses. I don't think the Window's warning is bogus, i.e. there has to be an IP conflict somewhere...
    Oh, and forgot. Get ready for a hair transplant as you may end up pulling it all out by the time it is all over!
    See below. I had a v1 so couldn't hard wire. Hard wire the RE to the computer instead of the router. Might be the IP conflict problem.
    From Castor post 05-29-07:
    Logon to setup page of your wireless router, get the necessary wireless settings e.g. SSID, channel, wireless security mode and security code, reset the R.E. (Range Expander) back to factory default settings by pressing reset button, power down the R.E. and connect directly to the computer, power up the R.E. and assign a static IP on pc e.g.192.168.1.10 subnet mask 255.255.255.0 default gateway 192.168.1.1, open I.E. on computer and in the address bar type 192.168.1.240, it would ask for username and password, put “admin” as password without any username, put the wireless settings according to wireless router and save the settings…power cycle the n/w by unplugging power cable of router and R.E. power up the router first once your router is rebooted power up the R.E. check whether it works or not and let me know…
    Message Edited by Luckydog on 07-05-2007 06:04 AM
    Message Edited by Luckydog on 07-05-2007 06:43 AM

Maybe you are looking for