Problem accessing mysql database

Hello all
I am using the following piece of code to access a database running remotely..I am using mysql-connector-java-3.1.0.
Connection C = DriverManager.getConnection(
"jdbc:mysql://***.***.***.***:3306/db1?user=\'******\'&password=\'*****\'");
In the above ***.***.***.*** is the ip address of the machine on which the database is there.
The error message is:
Invalid authorization specification: Access denied for user.
Please help me out on this. This is my first attempt to connect to MySQL from Java. Any code or comments and suggestions will be great.
thanks a bunch
Mahesh :)

hi
thanks a lot for ur reply...I had enuf rights to connect to the database....i recollected later that the right way to get the Connection object is like this:
Connection C = DriverManager.getConnection("jdbc:mysql://***.***.***.***:3306/db1?user=******&password=*****");
The name-value pairs like name and password need not have inverted commas...just user=soandso@password=soandso...
thanks a lot nyways...
Mahesh :)

Similar Messages

  • Accessing MySql database in jsp

    hi everyone!!!
    i m new to java with little knowledge of jsp.
    i want to access mysql database in jsp to develop a web page.
    i have jdk and mysql installed and these are working. what are other requirements and how to do this.
    plz help.
    OS: MS Windows XP/ Fedora 10

    Learn JDBC API: [http://java.sun.com/docs/books/tutorial/jdbc/index.html]. Create a DAO class which uses JDBC to interact with Java and takes or returns the desired data in form of DTO's. Use and test it as a plain vanilla Java application with a main() method. This require a JDBC driver (a concrete implementation of the JDBC API) in the classpath. MySQL offers JDBC drivers as download at their homepage, it is called "Connector/J".
    Once you got the JDBC part to work, create a Servlet class which holds an instance of the DAO class and uses its methods to interact with the database. In the doGet() you can place logic to preload data from the DAO class for display. In the doPost() you can place logic to process data for create, update or delete using the DAO class. Finally let it forward the request to a JSP.
    In the JSP you can use JSTL/EL to display data. For tabular view you may find the JSTL c:forEach useful. For plain display, just use EL the usual way.

  • Strange problem with MySQL database

    Hello,
    I'm totally puzzled by a strange error occurring with PHP/MySQL on my website... I hope someone has got an idea of what's going on and can let me know.
    In short, I have a MySQL database set up on the remote server where the website is hosted. Some pages of my website access this database with PHP.
    If the website is viewed with a browser in Windows (Firefox), it works well, the database data appear on the pages.
    If the website is viewed with a browser on Mac OS (Firefox, Safari), it doesn't work: the database isn't accessed, I get no error, just everything on the page below my PHP code is missing.
    I've attached two screenshots to show this. The website URL is: http://www.cerc.co.uk/CERC/v02/
    The pages were this occurs are: the home page (index.php and alternative index2.php), the Abous us/News page and the About us/News/Archives page.
    I really don't get where my mistake is. I would like to keep the remote server connexion details outside the root folder, but I guess that if there is no solution to this problem, then I'll have to move it back (I think it might have worked like that).
    Thanks in advance for any comment,
    Emilie
    More details
    I'm using DW CS4 on Windows XP emulated via VMware on Mac OS 10.5 (don't ask why, I wasn't given any choice). I've set up a localhost server on XP via XAMP and the news database is also there.
    Because I'm currently flipping often between the testing server and the remote server, I quickly got fed up to change all the time the connexion mode to the database (localhost or remote server) and have to resynchronise the files each time. Hence I decided to automate a bit the way the database is connected to.
    1. These 4 HTML pages with PHP code have got the below two lines when the PHP code starts:
    $pathpfx = "../.."; // see mysqlconnexion.php
    include('assets_design/php/mysqlconnexion.php');
    2. mysqlconnexion.php (see code below) calls a "connexion" file (in PHP) depending on the value of one parameter ($conxchoice). If $conxchoice = 1, the "connexion" file on the localhost is called. If $conxchoice = 2, the "connexion" file on the remote server is called. I've stored the appropriate version of mysqlconnexion.php on the localhost and the remote server (and I have checked it a million of times, they're in the right place).
    <?php
    // This code is called by and therefore included in the code of some PHP pages,
    // independently of where the pages are located within the website folder.
    // - Connexion to local server: I couldn't get the function include_once to work
    //   with a relative path, hence the use of an absolute path.
    // - Connexion to host server: I couldn't get the function include_once to work
    //   with an absolute path, hence the use of a relative path. This leads to the
    //   following problem: the path of conxsrv.php needs to be adapted to the
    //   position of the calling PHP page within the website, in order for
    //   conxsrv.php to be found on the server (it is located outside the website
    //   root folder). The variable $pathpfx is used for this purpose.
    $conxchoice = 2; // connect to 1 = testing server, 2 = host server
    // Connexion to database
    if ( $conxchoice == 1 )
    { include_once('C:\xampp\htdocs\CERC\assets_testing_server_only\conxloc.php'); }
    if ( $conxchoice == 2 )
    { include_once("$pathpfx/cgi-bin/sqlconx/conxsrv.php"); }
    ?>
    I would guess that a first hint of solution lies in the comment block, but I've really tried everything I could think of to work with relative path/absolute path respectively, unsuccessfully.
    3. The "connexion" file looks like:
    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_conx = "aaa";
    $database_conx = "bbb";
    $username_conx = "ccc";
    $password_conx = "ddd";
    $conx = mysql_pconnect($hostname_conx, $username_conx, $password_conx) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    With aaa, bbb, ccc and ddd the appropriate value depending on the file. The # lines were introduced by DW when these files were created (I've then changed the variable names and moved the files to another place).
    Screenshots

    Well, my question has actually not been answered yet but the problem, as strangely as it appeared, has now disappeared. Best but scariest of all, I didn't do anything. Weird.
    Hope it never comes back,
    Emilie

  • Accessing mysql database from oracle using dg4odbc

    I've been trying to create a database link from a MySQL database to Oracle using the Oracle dg4odbc gateway. I downloaded and installed DataDirect's ODBC package which includes mysql ODBC library (ddmysql24.so) and a generic ODBC libary (libodbc.so). After creating the DSN in odbc.ini, I tested it and it can connect to the mysql database. Then I created the init{SID}.ora file in hs/admin directory, added dg4odbc lines in the listener.ora, and added lines in tnsnames.ora. Then I tnspinged the new SID with success. Finally, I created the database link. However, when I tried to access the database link using the commands "select * from mdl_user@moodle;", I got the ORA-28500 error like the following:
    ERROR at line 1:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [DataDirect][ODBC 20101 driver][20101]You have an error in your SQL syntax;
    check the manual that corresponds to your MySQL server version for the right
    syntax to use near '"mdl_user"' at line 1
    ORA-02063: preceding 2 lines from MOODLE
    My mysql database is utf8 by default. Do I have to use latin1?
    It seems to me that the dg4odbc translates the sql commands incorrectly (having double quotes around the selected table).
    Any help is greatly appreciated.
    Jeffrey

    The syntax error occures for example when MySQL isn't running in ANSI mode and thus does not allow double quotes around the objects. DG4ODBC 11.1.0.6 by default always adds double quotes to table/column/view names.
    A quick test to check if you hit the double quote issue would be to set the MySQL DB into ANSI mode:
    - Open SQL*Plus
    - execute:
    DECLARE
    ret integer;
    c integer;
    BEGIN
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@moodle;
    DBMS_HS_PASSTHROUGH.PARSE@moodle(c, 'SET SESSION SQL_MODE=''ANSI_QUOTES'';');
    ret := DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@moodle(c);
    dbms_output.put_line(ret ||' passthrough output');
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@moodle(c);
    END;
    - Now run your select statement
    => if it now works, you can permanently change the MySQL config to be ANSI compliant or you can apply the 11.1.0.7 patchset to DG4ODBC.

  • Problem with Mysql DataBase

    hi all,
    I am new to this topic,so could any one please help me on this problem.
    How to Connect MySQL database with java ,
    I am getting errors with Driver and data source.
    which ODBC data source (user DSN,system DSN or file DSN ....)
    So please help me how to set the driver settings and how to connect it.
    If you have any example ....
    please post it
    thanks...

    sorry! this is the right one..
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class MYSQL
    Class.forName("org.gjt.mm.mysql.Driver");
    String url = "jdbc:mysql:databaseName";
    Connection con = DriverManager.getConnection (url, "loginID", "password");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * from javatest");
    while(rs.next()) {
    int pid = rs.getInt(1);
    String name = rs.getString(2);
    String address = rs.getString(3);
    String city = rs.getString(4);
    String state = rs.getString(5);
    String zip = rs.getString(6);
    String email = rs.getString(7);

  • Access MySQL Database on Server with PHP Services

    Hi there
    There are lots of tutorials on how to connect to a MySQL database on your local machine but I'd like to access a database on my server.
    When creating a new Flex Project the wizard asks me to define a Web root and a Root URL. I used '/home/ecoflexer/public_html' as Web root and 'http://ecoflexer.com' as Root URL. However, the Web root coudn't be validated. So I've chosen the local folder 'C:\ecoflexer' as Web root. Though it was possibly wrong Flash Builder generated a debug folder at the defined location. After that I went to "Connect to Data/Service" and selected "PHP Service". I tried to generate a sample using the same credentials I use for a standard PHP login script ("Server Port" was left empty). After clicking on "Connect to Database" Zend was installed and returned an error. 'gateway.php' couldn't be found on 'http://ecoflexer.com/testProject-debug/gateway.php'.
    So I went into my local Web root and copied the 'testProject-debug' folder to my server to the destination the previous error mentioned. Then another error occured concerning a Zend file. So I went back and copied the whole 'ZendFramework' folder as well to my server. It connects now successfully to my database. I can chose a table but soon after that the introspection of the service fails. I modified the 'amf_config.ini' by adding 'webroot =/home/ecoflexer/public_html' and 'zend_path =/home/ecoflexer/public_html/ZendFramework/library' but it's still not working. Anithing I've done wrong or forgot to do?
    Cheers!
    ecoFLEXER

    iam doing client server application,the database is on the server,and iam doing the log in part,so i need to access the database to match the entered user name and password?so i should implement the accessing database part on the server side with the above code,right?i didn't test that i will test it now,but i thought that it's a different way

  • Problem Seeing MySQL Database

    I am trying to migrate a MySQL 5 database to Oracle. Using these forums, I successfully resolved my connections problems, but now I have a new issue. When trying to capture my database, the capture screen connects to the server and then gives me a list of databases that I can capture. The problem is that it only lists the "test" database, not the "mysql" database where the data is.
    Any ideas why it does not see all the databases?

    the user root must have
    mysql>grant all on *.* on root;
    How did you get run the mysql 5 plugin?
    I just see plugin for mysql v 3 and 4.
    Thanks
    Murcia

  • Problem Accessing MySQL on OSX 10.2.8

    Hi,
    Hope this is the right board.
    I installed myql 4.0.25 on my eMac running OSX 10.2.8 some time ago. Now when I try to access mysql via Terminal I get
    /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user: 'root@localhost' (Using password: NO)'
    At no point did it ask me for a password, so I'm confused. I am not a UNIX enlightened user, this is my first real delve into it, as I want to learn PHP and database driven sites. I don't really have a clue what I'm doing !
    When I originally set it up I set passwords for the root and user accounts, but when I am asked for a password these don't work. I got mysqld_safe running, so that part is working, I just can't seem to do any thing to enter either mysql or mysqladmin.
    Do I need to uninstall MySQL and start again?
    Any help appreciated.
    Cheers,
    Tracy
    G4 400MHz (PCI) 384MB RAM   Mac OS X (10.2.x)  

    Hi,
    use mysqladmin with the -p option. This prompts you for a password and you should give the mySQL root password (the one you once set) here.
    Volker

  • Accessing mySQL database from Labview PDA

    Hi,
    Has anyone tried writing data to a mySQL database or any other database for that matter using the Labview PDA module?  I know it's easy to do from Labview and you have to download the ODBC drivers to get it working but I don't think these drivers are available for Windows Mobile (I've seen XP and Linux drivers only).  Any help would be appreciated.
    Thanks

    Hello,
    I don't have experience with this, but you might look into the following:
    1. remote connections: http://www.geekzone.co.nz/content.asp?contentid=2656
    2. this thread seems to indicate .NET doesn't support it yet (but it's over a year old...): http://forums.mysql.com/read.php?38,73109,73109
    3. Another option - you can use VI Server to have your PDA VI call a VI on your host machine if they are networked... there is an example of this that ships with LabVIEW PDA I think - check it out!  Thus, if the db is on your host machine, you could write your host VI, and have your PDA VI call it etc.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Error accessing mysql database from a remote host

    Hi all,
    I'm running the following PL/SQL script and encountered some errors. The MySQL server is hosted off campus by a hosting company. However, when I run the same script against a MySQL database server hosted on campus, the script works fine. Here's the error:
    ERROR at line 3:
    ORA-04052: error occurred when looking up remote object
    cmswhit_odbc13.mdl_user@RLTEST
    ORA-00604: error occurred at recursive SQL level 1
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [MySQL][ODBC 5.1 Driver][mysqld-4.1.22-standard]SELECT command denied to user
    'cmswhit_odbc13'@'192.160.216.13' for table 'mdl_user'
    ORA-02063: preceding 2 lines from RLTEST
    Here's the script:
    sqlplus -s <<endofit
    $USERPASS
    set serveroutput on;
    DECLARE
    user_name varchar2(30);
    moo_user_name varchar2(300);
    routine VARCHAR2(40);
    cntr NUMBER(8);
    CURSOR read_saradap is
    select gobtpac_external_user
    from gobtpac
    where gobtpac_external_user in ('greenup','yfeng');
    CURSOR read_mdl_user is
    select "username" from "mdl_user"@rltest where "username" = user_name;
    -- E N D O F C U R S O R S --
    BEGIN
    dbms_output.enable(1000000000);
    -- STEP 1: Read through Banner
    cntr := 0;
    OPEN read_saradap;
    LOOP
    routine := 'Read applicant';
    -- Read an applicant record
    dbms_output.put_line('Reading Banner user');
    FETCH read_saradap INTO user_name;
    EXIT WHEN read_saradap%NOTFOUND;
    dbms_output.put_line('Read Banner username=' || user_name);
    cntr := cntr + 1;
    -- Read the Moodle user;
    routine := 'Read moodle user';
    OPEN read_mdl_user;
    FETCH read_mdl_user INTO moo_user_name;
    IF read_mdl_user%NOTFOUND THEN
    dbms_output.put_line('Moodle user not found');
    ELSE
    dbms_output.put_line('Read Moodle username=' || moo_user_name);
    END IF;
    CLOSE read_mdl_user;
    END LOOP;
    rollback;
    CLOSE read_saradap;
    dbms_output.put_line('Total processed: ' || cntr);
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLCODE);
    dbms_output.put_line(SQLERRM);
    dbms_output.put_line('Error user=' || user_name);
    dbms_output.put_line(routine);
    END;
    EXIT;
    endofit

    The error seems to be quite clear: the user 'cmswhit_odbc13'@'192.160.216.13' lacks the SELECT privilege on the 'mdl_user' table...
    Max
    http://oracleitalia.wordpress.com

  • Problem updating mySQL database

    I am trying to update some data in one of my tables called topic in my SQL database. I have the follwing code which gets data from a bean and updates it in the database but it does not seem to work. I do not get an exception but it will not update the record even though the bean displays the correct information about the update it does not seem to update the database, Does anyone have any idea where i am going wrong?
    String updateTopic__topicID = null;
    if (request.getParameter("topicID") != null) {
        updateTopic__topicID = (String)request.getParameter("topicID");
    String insertTopic__username = null;
    if (session.getValue("MM_Username") != null) {
        insertTopic__username = (String)session.getValue("MM_Username");
    Driver DriverupdateTopic   = (Driver)Class.forName(MM_connQuestion_DRIVER).newInstance();
    Connection ConnupdateTopic = DriverManager.getConnection(MM_connQuestion_STRING, MM_connQuestion_USERNAME,
                                                             MM_connQuestion_PASSWORD);
    PreparedStatement updateTopic =
                          ConnupdateTopic.prepareStatement("UPDATE Question.topic  SET Topic_Name = '" + topicData.topicName
                                                               + "', Description = '" + topicData.topicDescription
                                                               + "'  WHERE Topic_ID = '" + updateTopic__topicID + "' ");
    updateTopic.executeUpdate();

    I tried to check it and it did not update any records
    cos i got this.
    Records updated: 0
    The WHERE claus does match my database record because
    it is called Topic_ID which is the primary key for
    that table. could it be something that is wrong with
    my database?
    Sir,
    That is unlikely.
    What is more likely is that something is wrong with your code somewhere.
    I am somewhat suspicious of the STRING nature of Topic_ID. That is an auto_incrementing field I think? If so try setInt or setLong.
    And to answer the followup question to that.
    int anintvalue = Integer.parseInt(astringvalue);The other possibility is that in your form or whatever the value of the Topic_ID is getting mucked up. I would check to make sure you have the value you think.
    Finally always make sure you are talking to the database you think you are. I realize this seems stupid but in testing environments these things do happen more often then one might suppose.
    Sincerely,
    Slappy

  • Problem with connection in Mysql database in struts application

    Helllo
    i've just started learning struts for my new project where i'm having problem in accessing mysql database
    the datasource being defined in struts-config.xml is as follows:
    <data-sources >
        <data-source type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
          <set-property property="driverClassName" value="com.mysql.jdbc.Driver" />
          <set-property property="user" value="root" />
          <set-property property="password" value="" />
          <set-property property="minCount" value="" />
          <set-property property="maxCount" value="" />
          <set-property property="description" value="A" />
          <set-property property="url" value="jdbc:mysql:///dnbotind_nbotdb" />
          <set-property property="readOnly" value="false" />
          <set-property property="autoCommit" value="true" />
          <set-property property="loginTimeout" value="" />
        </data-source>
      </data-sources>as i run the application
    it gives the errors HTTP status 404-Servlet action is not available
    Thx in advance

    student-java wrote:
    it gives the errors HTTP status 404-Servlet action is not availableThis is unrelated to the datasource configuration.
    HTTP 404 is a "Page not found" error. The request URL is simply wrong. Either there's a typo in the URL, or there is a typo in the servlet mapping, or the servlet is not there where you think.

  • Problem creating connection pool to mysql database

    Please, do not ignore this message and help me, if you have any Idea
    I have Sun Java System Application Server 8.1 installed on my computer, I installed also MySQL Connector/J to access MySql Databases through JDBC
    But now when I try to create new connection pool, an error comes:
    Following parameter were used:
    Name: MYSQL1
    Resource Type: javax.sql.XADataSource
    Database Vendor: mysql
    Datasource Classname: com.mysql.jdbc.Driver
    serverName 192.168.0.152
    port 3306
    networkProtocol
    user testuser
    password ***
    databaseName test
    datasourceName
    After saving and then klicking on Ping button, following error comes: "An error has occurred.
    Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: com.mysql.jdbc.Driver"
    I checked the logs of MySql, there was no attempt to access given Database or MYSQL-server at all
    What Am I doing wrong? How can I create MySql connection under Sun Java System Application Server 8.1?
    Any help will be appreciated

    The driver is in right place
    Originally I placed him in wrong directory and got an error, indicationg, that Driver class is not found, but then I corrected it, The problem is in connection to database - it doesn't work.
    I tired to load the same driver into Netbeans and could easyli create a connection to database, but I get it not working ander Sun Application server

  • Error in Mysql database connectivity

    hello,
    there is problem in Mysql database connectivity.
    when i connect JSP program to Mysql database it gives error :
    Server configuration denied access to data source
    please help me asap
    kuldip jain
    [email protected]

    i m also working on Mysql Java but on Window 2000 platform
    here is the Java code which successfully runing on my machine
    import java.sql.*;
    public class TestMySql
         public static void main(String[] Args)
              try
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection C = DriverManager.getConnection(
    "jdbc:mysql://server2:3306/Db?user=root");
    Statement Stmt = C.createStatement();
    ResultSet RS = Stmt.executeQuery("SELECT * from T1");
    while (RS.next()) {
                             System.out.println(RS.getString(1));
    catch (Exception E)
    System.out.println("SQLException: " + E.getMessage());

  • Database Link to Mysql Database.

    Hi Guys.
    I need to Create a Database Link a Mysql database that is running over a Red Hat server to my Oracle 10g Database that is running over SUSE. I Have an Application server where the user runs forms and Report. The user access the Application Server that allow them to connect to Oracle Database because is a web Environtment. I would like to access MYSQL database to pull our some data to create a couple of Views for my Users.
    Thanks in Advance.
    Emmanuel
    PD: do I need to configure some ODBC or just modify my tnsname.ora file???

    add a space to each line in the SID section of your listener - only GTW_LISTENER and SID_LIST_GTW_LISTENER are valid commands to start at the first position in the file.
    In addition please remove that line from your gateway init file: HS_FDS_SHAREABLE_NAME=C:\Program Files\MySQL\Connector ODBC 5.2\myodbc5w.dll
    HS_FDS_SHAREABLE_NAME is used on Unix to specify the ODBC Driver Manager - as you're on Windows where Windoes ships a valid ODBC Driver Manager you don't need to specify that parameter.manager. In addition please remove the set ODBCINI parameter as the Windows ODBC Driver Manager uses the registry. So make sure you have created a 64bit ODBC system DSN using the 64bit MySQL ODBC driver (it has to be the 64bit ODBC driver as you're on a 64bit Windows using a 64bit DG4ODBC)
    - Klaus

Maybe you are looking for

  • Serial number related sales orders???

    Hi everyone, i got this problem when i try to use serial number of an equipment to search all related sales orders. in our company it is defined that serial number would be created in the first sales order, when the customer purchase the configurable

  • Auto update of picking/putaway qty

    Hi friends, In transaction VL01N/VL31N, we need to auto update of picking/putaway quantity from delivery quantity when an Outbound/Inbound delivery is created. We try to do this with form exit USEREXIT_SAVE_DOCUMENT (include MV50AFZ1) and USEREXIT_MO

  • Ichat audio video options for google accts

    Hi, 1. I use ichat with my google account. I was wondering if I could do an audio and video chat from this account? 2. Also, if I disable my camera (in format tab), and press on the audio option beside my picture in the chat list, why is isight cam g

  • Reference date of last data load in query

    Is it possible to referece the date of the data load in a query via user exit / formula variable or some other way? We have a requirement to display data in a query based on when the data was last loaded. If the data load has not occured this month,

  • Rule around text boxes?

    How do we remove the rule around text boxes?