Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 62030 invoked from network); 23 Mar 2008 07:09:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Mar 2008 07:09:21 -0000 Received: (qmail 56962 invoked by uid 500); 23 Mar 2008 07:09:19 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 56925 invoked by uid 500); 23 Mar 2008 07:09:18 -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 56914 invoked by uid 99); 23 Mar 2008 07:09:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Mar 2008 00:09:18 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ycol@hotmail.com designates 65.54.246.140 as permitted sender) Received: from [65.54.246.140] (HELO bay0-omc2-s4.bay0.hotmail.com) (65.54.246.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Mar 2008 07:08:28 +0000 Received: from BAY109-W13 ([64.4.19.113]) by bay0-omc2-s4.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 23 Mar 2008 00:08:48 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_255bfa9a-0f3b-4bb7-8935-d5d2e8eb2aa5_" X-Originating-IP: [66.214.247.215] From: Milind W To: Subject: jdbc:default:connection fails Date: Sun, 23 Mar 2008 03:08:48 -0400 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 23 Mar 2008 07:08:48.0418 (UTC) FILETIME=[BDAB4820:01C88CB4] X-Virus-Checked: Checked by ClamAV on apache.org --_255bfa9a-0f3b-4bb7-8935-d5d2e8eb2aa5_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hi, I have written a java function as below. I am testing it using squirrel sql= client and embedded derby. The function is being invoked but jdbc:default:= connection returns null. I have tried both adding and removing the Class.fo= rName line with not much difference. My errorlog file shows me a java.lang.NullPointerException and my execution= log has not gone beyond step 1 (that is it fails at getconnection). Can so= meone pelase help. Cheers -Milind package com.myorg.derbyfunctions; import java.sql.*; import java.util.*; import java.io.*; public class ActiveOrg { =20 public static String GetActiveOrg (String status) { String org =3D "original"; try { BufferedWriter out2 =3D new BufferedWriter(new FileWriter("C:\\ActiveOr= gLog.txt")); out2.write("1"); out2.flush(); //Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Connection conn =3D DriverManager.getConnection("jdbc:default:conne= ction"); out2.write("2"); out2.flush(); String query =3D "INSERT into obj(TYPE) values('+status+')"; out2.write("3"); out2.flush(); System.out.println("Query"+query); Statement stmnt =3D conn.createStatement(); stmnt.execute(query); stmnt.close(); conn.close(); out2.close(); } catch (Exception ex) { try { BufferedWriter out =3D new BufferedWriter(new FileWriter("C:\\Activ= eOrgError.txt")); out.write(ex.toString()); out.close(); } catch(Exception ex2) { ex2.printStackTrace(); } =20 } return org; } } /* Declared as follows: CREATE FUNCTION GetActiveOrg (status STRING) RETURNS VARCHAR(255) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA EXTERNAL NAME 'com.mymunshi.derbyfunctions.ActiveOrg.GetActiveOrg' Invoked as follows VALUES getactiveorg('Active') */ --_255bfa9a-0f3b-4bb7-8935-d5d2e8eb2aa5_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
hi,
I have written a java function as below. I am testing it using s= quirrel sql client and embedded derby. The function is being invoked but jd= bc:default:connection returns null. I have tried both adding and removing t= he Class.forName line with not much difference.
My errorlog file shows m= e a java.lang.NullPointerException and my execution log has not gone beyond= step 1 (that is it fails at getconnection). Can someone pelase help.
Ch= eers
-Milind

package com.myorg.derbyfunctions;
import java.sql= .*;
import java.util.*;
import java.io.*;

public class ActiveO= rg
{  
    public static String GetActiveOr= g (String status)
    {
    String org = =3D "original";
    try
    {
 =    BufferedWriter out2 =3D new BufferedWriter(new FileWriter("C:\= \ActiveOrgLog.txt"));
    out2.write("1");
  = ;  out2.flush();
    //Class.forName("org.apache.der= by.jdbc.EmbeddedDriver").newInstance();
     &n= bsp;  Connection conn =3D DriverManager.getConnection("jdbc:default:co= nnection");
    out2.write("2");
    ou= t2.flush();
    String query =3D "INSERT into obj(TYPE) v= alues('+status+')";
    out2.write("3");
  &= nbsp; out2.flush();
    System.out.println("Query"+query)= ;
    Statement stmnt =3D conn.createStatement();
&nbs= p;    stmnt.execute(query);
     = ;           stmnt.close()= ;
        conn.close();
 &nbs= p;  out2.close();
    }
    &= nbsp;      catch (Exception ex)
  &nb= sp;     {
       = try
        {
   &= nbsp;    BufferedWriter out =3D new BufferedWriter(new FileW= riter("C:\\ActiveOrgError.txt"));
      &n= bsp; out.write(ex.toString());
       = ; out.close();
        }
 &nb= sp;      catch(Exception ex2)
   = ;     {
        e= x2.printStackTrace();
        } =  
        }
  &nbs= p; return org;

    }
}

/*
Declared as fo= llows:
CREATE FUNCTION GetActiveOrg (status STRING)
RETURNS VARCHAR(2= 55)
LANGUAGE JAVA
PARAMETER STYLE JAVA
READS SQL DATA
EXTERNAL = NAME 'com.mymunshi.derbyfunctions.ActiveOrg.GetActiveOrg'

Invoked as= follows
VALUES getactiveorg('Active')
*/




= --_255bfa9a-0f3b-4bb7-8935-d5d2e8eb2aa5_--