Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A0EA877F for ; Mon, 8 Aug 2011 20:54:26 +0000 (UTC) Received: (qmail 75172 invoked by uid 500); 8 Aug 2011 20:54:25 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 75119 invoked by uid 500); 8 Aug 2011 20:54:24 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 75112 invoked by uid 99); 8 Aug 2011 20:54:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Aug 2011 20:54:24 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of roy.minet@comcast.net designates 76.96.59.212 as permitted sender) Received: from [76.96.59.212] (HELO qmta14.westchester.pa.mail.comcast.net) (76.96.59.212) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Aug 2011 20:54:15 +0000 Received: from omta19.westchester.pa.mail.comcast.net ([76.96.62.98]) by qmta14.westchester.pa.mail.comcast.net with comcast id Hwru1h00B27AodY5EwtuHD; Mon, 08 Aug 2011 20:53:54 +0000 Received: from sz0138.wc.mail.comcast.net ([76.96.58.202]) by omta19.westchester.pa.mail.comcast.net with comcast id Hwtt1h01w4MnWwC3fwttl0; Mon, 08 Aug 2011 20:53:53 +0000 Date: Mon, 8 Aug 2011 20:53:53 +0000 (UTC) From: Roy.Minet@comcast.net To: Derby Discussion Message-ID: <785273626.393012.1312836833756.JavaMail.root@sz0138a.westchester.pa.mail.comcast.net> In-Reply-To: <4E4037D9.7030405@oracle.com> Subject: Re: Can't Load Embedded Driver MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_393011_338517847.1312836833756" X-Originating-IP: [174.54.64.45] X-Mailer: Zimbra 6.0.10_GA_2706 (ZimbraWebClient - IE8 (Win)/6.0.10_GA_2697) X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_393011_338517847.1312836833756 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable That bottom level plumbing has been working perfectly for two years in dev.= =C2=A0 I remember thinking it was pretty cool and developer-friendly.=C2=A0= I had essentially NO trouble getting it all up and working.=C2=A0 I have n= ow added the code to explicitly load the driver.=C2=A0 It works fine in dev= , but not deployed in a jar (java.lang.ClassNotFoundException: org.apache.d= erby.jdbc.EmbeddedDriver).=C2=A0=C2=A0CLASSPATH surely would be the usual s= uspect, but echo %CLASSPATH% yields " C:\Program Files\Apache\db-derby-10.8= .1.2-bin\lib\derby.jar;." (derby.jar really IS in that location) =C2=A0and= =C2=A0 java org.apache.derby.jdbc.EmbeddedDriver yields "Exception in threa= d "main" java.lang.NoSuchMethodError: main" as Rick says it should.=C2=A0 S= o, WTF am I doing wrong?=C2=A0 In Unix, I would have double-checked rwx per= missions (maybe Intellij Idea is running as root) , but I'm not as familiar= with this stuff in Windows.=20 ----- Original Message ----- From: "Rick Hillegas" =20 To: "Derby Discussion" =20 Sent: Monday, August 8, 2011 3:24:09 PM=20 Subject: Re: Can't Load Embedded Driver=20 Hi Roy,=20 Thanks for including the code snippet. As Raymond points out, you are=20 not loading the driver explicitly. This should not be necessary if you=20 are using Java 6 or 7. However, driver autoloading does not happen in=20 Java 5 and earlier versions of Java. What version of Java are you using?=20 Thanks,=20 -Rick=20 On 8/8/11 11:55 AM, Raymond Kroeker wrote:=20 > Hi Roy,=20 >=20 > The fqcn, is the fully qualified class name of the driver. =C2=A0So in yo= ur=20 > code you're using the driver manager to grab a connection; however I=20 > don't see a reference to loading the driver:=20 > http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html#embedded_d= river=20 >=20 > Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();=20 >=20 > Raymond=20 >=20 > On Mon, Aug 8, 2011 at 11:47, =C2=A0wrote:=20 >> I do not know what an "fqcn" is. =C2=A0I am running the latest Derby rel= ease,=20 >> 10.8.1.2. =C2=A0The code pasted in below works great in the dev environm= ent=20 >> (IntelliJ Idea), but the same code packaged in a jar cannot find the dri= ver=20 >> with CLASSPATH set correctly.=20 >>=20 >> =C2=A0 =C2=A0 public static Connection getConnection()=20 >> =C2=A0 =C2=A0 {=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0Connection c =3D null;=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0try=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0{ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /= / The connectionURL=20 >> is "jdbc:derby:EMDatabase;create=3Dtrue"=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 c =3D DriverManager.getConnection(con= nectionURL);=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 c.setAutoCommit(false);=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0}=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0catch (Throwable e)=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0{=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 log(3, "Unable to connect to " + dbNa= me + ": =C2=A0" + e.getMessage());=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stopDBMS();=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 System.exit(3);=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0}=20 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0return c;=20 >> =C2=A0 =C2=A0 }=20 >>=20 >>=20 >>=20 >> ________________________________=20 >>=20 >> From: "Raymond Kroeker"=20 >>=20 >> To: "Derby Discussion"=20 >> Sent: Monday, August 8, 2011 10:08:11 AM=20 >> Subject: Re: Can't Load Embedded Driver=20 >>=20 >> Can you try specifying the driver as a fqcn? If that doesn't solve the i= ssue=20 >> please paste relevant code around how you load the driver and obtain a= =20 >> connection.=20 >>=20 >> Raymond=20 >>=20 >> On Aug 8, 2011 6:55 AM, =C2=A0wrote:=20 >>>=20 >>> Rick,=20 >>>=20 >>>=20 >>>=20 >>> Thank you very much for offering your help. =C2=A0Apparently my CLASSPA= TH is=20 >>> good. =C2=A0I typed in "java org.apache.derby.jdbc.EmbeddedDriver" and = did indeed=20 >>> get exactly the expected "Exception in thread "main"=20 >>> java.lang.NoSuchMethodError: main" error message. =C2=A0What else could= be=20 >>> causing =C2=A0my problem?=20 >>>=20 >>>=20 >>>=20 >>> Roy=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>> ----- Original Message -----=20 >>>=20 >>>=20 >>> From: "Rick Hillegas"=20 >>> To: "Derby Discussion"=20 >>> Sent: Monday, August 8, 2011 9:00:58 AM=20 >>> Subject: Re: Can't Load Embedded Driver=20 >>>=20 >>> On 8/7/11 9:54 AM, Roy.Minet@comcast.net wrote:=20 >>>> I have been happily using Derby for two years within IntelliJ Idea,=20 >>>> but have now hit a wall trying to deploy the application I developed.= =20 >>>> I have tried setting the path to derby.jar on the command line and/or= =20 >>>> in the CLASSPATH environment variable to no avail. =C2=A0The embedded= =20 >>>> driver doesn't load; the error message is, "No suitable driver found= =20 >>>> for jdbc:derby:EMDatabase;create=3Dtrue". =C2=A0I'm under Windows XP P= ro.=20 >>>> Any help would be appreciated.=20 >>>>=20 >>>> Roy Minet=20 >>>>=20 >>>>=20 >>> Hi Roy,=20 >>>=20 >>> This is almost always a CLASSPATH problem. With the same CLASSPATH, try= =20 >>> the following experiment:=20 >>>=20 >>> java org.apache.derby.jdbc.EmbeddedDriver=20 >>>=20 >>> If the CLASSPATH is good, you should see this error:=20 >>>=20 >>> Exception in thread "main" java.lang.NoSuchMethodError: main=20 >>>=20 >>> Hope this helps,=20 >>> -Rick=20 >=20 >=20 ------=_Part_393011_338517847.1312836833756 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: Arial; font-size: 12pt; color: #000000'>That bott= om level plumbing has been working perfectly for two years in dev.  I = remember thinking it was pretty cool and developer-friendly.  I had es= sentially NO trouble getting it all up and working.  I have now added = the code to explicitly load the driver.  It works fine in dev, but not= deployed in a jar (java.lang.ClassNotFoundException: org.apache.derby.jdbc= .EmbeddedDriver).  CLASSPATH surely would be the usual suspect, b= ut echo %CLASSPATH% yields "C:\Program Files\Apache\db-derby-10.8.1.2-bin\l= ib\derby.jar;." (derby.jar really IS in that location) and  java = org.apache.derby.jdbc.EmbeddedDriver yields "Exception in thread "main" jav= a.lang.NoSuchMethodError: main" as Rick says it should.  So, WTF am I = doing wrong?  In Unix, I would have double-checked rwx permissions (ma= ybe Intellij Idea is running as root), but I'm not as familiar with this st= uff in Windows.


From: "Rick Hillegas" <rick.hillegas@oracle.com>
To: "Derby Discussion" <derby-user@db.apache.org>
Sent: Monday= , August 8, 2011 3:24:09 PM
Subject: Re: Can't Load Embedded Driv= er

Hi Roy,

Thanks for including the code snippet. As Raymond = points out, you are
not loading the driver explicitly. This should not = be necessary if you
are using Java 6 or 7. However, driver autoloading = does not happen in
Java 5 and earlier versions of Java. What version of= Java are you using?

Thanks,
-Rick

On 8/8/11 11:55 AM, Ray= mond Kroeker wrote:
> Hi Roy,
>
> The fqcn, is the fully = qualified class name of the driver.  So in your
> code you're us= ing the driver manager to grab a connection; however I
> don't see a = reference to loading the driver:
> http://db.apache.org/derby/papers/= DerbyTut/embedded_intro.html#embedded_driver
>
> Class.forName(= "org.apache.derby.jdbc.EmbeddedDriver").newInstance();
>
> Raym= ond
>
> On Mon, Aug 8, 2011 at 11:47,<Roy.Minet@comcast.net&= gt;  wrote:
>> I do not know what an "fqcn" is.  I am ru= nning the latest Derby release,
>> 10.8.1.2.  The code pasted= in below works great in the dev environment
>> (IntelliJ Idea), b= ut the same code packaged in a jar cannot find the driver
>> with = CLASSPATH set correctly.
>>
>>     public stati= c Connection getConnection()
>>     {
>>  =      Connection c =3D null;
>>      = ;  try
>>        {       &= nbsp;     // The connectionURL
>> is "jdbc:derby:EMDatab= ase;create=3Dtrue"
>>           c =3D Dri= verManager.getConnection(connectionURL);
>>       &= nbsp;   c.setAutoCommit(false);
>>        = ;}
>>        catch (Throwable e)
>> &= nbsp;      {
>>           = log(3, "Unable to connect to " + dbName + ":  " + e.getMessage());
= >>           stopDBMS();
>>   =         System.exit(3);
>>      = ;  }
>>        return c;
>> &nbs= p;   }
>>
>>
>>
>> _______________= _________________
>>
>> From: "Raymond Kroeker"<raykro= eker@gmail.com>
>>
>> To: "Derby Discussion"<derby-= user@db.apache.org>
>> Sent: Monday, August 8, 2011 10:08:11 AM=
>> Subject: Re: Can't Load Embedded Driver
>>
>>= ; Can you try specifying the driver as a fqcn? If that doesn't solve the is= sue
>> please paste relevant code around how you load the driver a= nd obtain a
>> connection.
>>
>> Raymond
>= >
>> On Aug 8, 2011 6:55 AM,<Roy.Minet@comcast.net>  = ;wrote:
>>>
>>> Rick,
>>>
>>&g= t;
>>>
>>> Thank you very much for offering your he= lp.  Apparently my CLASSPATH is
>>> good.  I typed in= "java org.apache.derby.jdbc.EmbeddedDriver" and did indeed
>>>= get exactly the expected "Exception in thread "main"
>>> java.= lang.NoSuchMethodError: main" error message.  What else could be
&g= t;>> causing  my problem?
>>>
>>>
>= ;>>
>>> Roy
>>>
>>>
>>&g= t;
>>>
>>>
>>> ----- Original Message -= ----
>>>
>>>
>>> From: "Rick Hillegas"&= lt;rick.hillegas@oracle.com>
>>> To: "Derby Discussion"<d= erby-user@db.apache.org>
>>> Sent: Monday, August 8, 2011 9:= 00:58 AM
>>> Subject: Re: Can't Load Embedded Driver
>>= ;>
>>> On 8/7/11 9:54 AM, Roy.Minet@comcast.net wrote:
&g= t;>>> I have been happily using Derby for two years within Intelli= J Idea,
>>>> but have now hit a wall trying to deploy the ap= plication I developed.
>>>> I have tried setting the path to= derby.jar on the command line and/or
>>>> in the CLASSPATH = environment variable to no avail.  The embedded
>>>> dr= iver doesn't load; the error message is, "No suitable driver found
>&= gt;>> for jdbc:derby:EMDatabase;create=3Dtrue".  I'm under Windo= ws XP Pro.
>>>> Any help would be appreciated.
>>&g= t;>
>>>> Roy Minet
>>>>
>>>>= ;
>>> Hi Roy,
>>>
>>> This is almost al= ways a CLASSPATH problem. With the same CLASSPATH, try
>>> the = following experiment:
>>>
>>> java org.apache.derby= .jdbc.EmbeddedDriver
>>>
>>> If the CLASSPATH is go= od, you should see this error:
>>>
>>> Exception in= thread "main" java.lang.NoSuchMethodError: main
>>>
>>= ;> Hope this helps,
>>> -Rick
>
>

<= /body> ------=_Part_393011_338517847.1312836833756--