List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:September 8 1999 3:38pm
Subject:Re: jdbc connect
View as plain text  
Stephen Uczekaj wrote:
> 
> > Date: Mon, 16 Aug 1999 18:35:26 +0200
> > From: "Christian Mack" <Mack@stripped>
> > X-Accept-Language: de,de-DE,de-CH,de-AT,en,en-GB,en-US
> > MIME-Version: 1.0
> > To: Stephen Uczekaj <uczekaj@stripped>
> > CC: mysql@stripped
> > Subject: Re: jdbc connect
> > Content-Transfer-Encoding: 7bit
> > X-MDaemon-Deliver-To: uczekaj@stripped
> > X-Return-Path: Mack@stripped
> >
> > Stephen Uczekaj wrote:
> > >
> > > I have been using mysql for the last 3 weeks and have had no problems
> until
> now.
> > >  This morning I logged in to my solaris box and started
> > > mysql-3.22.23b-sun-solaris2.6-sparc, and now the java code below is giving
> me an
> > > SQL Exception error 'Server configuration denies access to data source'
> > >
> > > It doesn't matter what I put in for The_Host, The_DB, The_User, The_Pwd I
> get
> > > the same error (even when setting The_User/The_Pwd to root)!  The driver
> is
> > > org.gjt.mm.mysql.  I can still access mysql through the command line using
> > > >bin/mysql -u root -p
> > >
> > > Any ideas why this is happening?
> > >
> > > thanks, steve u.
> > >
> > >    public void Connect()
> > >    {
> > >       try
> > >       {
> > >          Class.forName(The_Driver).newInstance();
> > >       }
> > >       catch (Exception e)
> > >       {
> > >          System.out.println("Class.forName() Exception: " + e);
> > >       }
> > >
> > >       try
> > >       {
> > >          String connectstr = The_Url + "://" + The_Host + "/" + The_DB +
> ",
> " +
> > > The_User
> > >  + ", " + The_Pwd;
> > >
> > >          JDBC_Connection = DriverManager.getConnection(connectstr);
> > >       }
> > >       catch (java.sql.SQLException e)
> > >       {
> > >          System.out.println("\nConnect() SQL Exception: " + e.getMessage()
> +
> "\n
> > > ");
> > >       }
> > >
> > >    }
> >
> > Hi Stephen
> >
> > You use an illegal URL string!
> > This can't work!!!
> >
> > Use this instead:
> > ...
> >         String connectstr = The_Url + "://" + The_Host + "/" + The_DB;
> >         JDBC_Connection = DriverManager.getConnection( connectstr, The_User,
> The_Pwd );
> > ...
> >
> > Tschau
> > Christian
> >
> 
> The code is correct and results in exactly the same parameters as you show (look
> closely at the connectstr which includes commas for the The_User, The_Pwd).
> This was working fine, and only recently started giving me the error mentioned.
> 
> steve u.

Hi Steve

You are wrong here!
The JDBC specification gives the URL as:
jdbc:<driver_specific_name>://<host>:<port>/<database_to_use>?<param1>=<something>&<param2>=<others>&...

You try to use:
jdbc:<driver_specific_name>://<host>:<port>/<database_to_use>,<username>,<password>

You use the getConnection(String) method and I use the getConnection(String,String,String)
method this is not the same!!

I assume, you changed the default user and password settings in mysql.
Before it worked, because your JDBC driver used some valid default values for user and
password.

Please try my suggestion.

Tschau
Christian

PS: Sorry for the late answer, I was really busy.

Thread
jdbc connectStephen Uczekaj13 Aug
  • Re: jdbc connectChristian Mack16 Aug
Re: jdbc connectStephen Uczekaj17 Aug
  • Re: jdbc connectChristian Mack8 Sep