Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

problems with "java in the database"

6 posts in General Discussion Last posting was on 2003-03-11 13:05:35.0Z
Christian_R. Posted on 2003-03-08 15:27:03.0Z
From: Christian_R.
Date: Sat, 8 Mar 2003 10:27:03 -0500
Newsgroups: ianywhere.public.general
Subject: problems with "java in the database"
Message-ID: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums>
Lines: 19
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub ianywhere.public.general:801
Article PK: 3287

i try to use java in the database but it does not work.
i have already installed a little java class at my database and made a new
table which uses this class. if i try to put a new entry in this table i
get following error message: "MyClass is not a public Java class, and
cannot be referenced from SQL." (ASA error 762)

the code of my class:

public class MyClass {
public java.lang.Integer key;
public String data;

public MyClass() {
key = new java.lang.Integer(7);
data = "Ich enthalte die Daten";
}
}

well, i think my class is public... have i forgotten something?


Nick Elson Posted on 2003-03-10 15:53:50.0Z
From: "Nick Elson" <no_spam_nicelson@sybase.com>
References: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums>
Subject: Re: problems with "java in the database"
Date: Mon, 10 Mar 2003 10:53:50 -0500
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <w#epVAy5CHA.308@forums.sybase.com>
Newsgroups: ianywhere.public.general
NNTP-Posting-Host: 172.31.142.76
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub ianywhere.public.general:802
Article PK: 3279

A quick tip may be to remove the "target" option while compiling.

We usually see this error if you get the package wrong but

BUT if the above does not help:

Can you supply what exactly you are doing here?

We would likely need to know the following:

the ASA version (and ebf)
the java version upgraded into the database,
JDK version for javac,
the command line used to compile the class,
(or the IDE used),
the create table statement,
the insert statement (or script or procedure definition),
the jar name,
. . .
anything else necessary for someone else to try this.

<Christian_R.> wrote in message
news:9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums...
> i try to use java in the database but it does not work.
> i have already installed a little java class at my database and made a new
> table which uses this class. if i try to put a new entry in this table i
> get following error message: "MyClass is not a public Java class, and
> cannot be referenced from SQL." (ASA error 762)
>
> the code of my class:
>
> public class MyClass {
> public java.lang.Integer key;
> public String data;
>
> public MyClass() {
> key = new java.lang.Integer(7);
> data = "Ich enthalte die Daten";
> }
> }
>
> well, i think my class is public... have i forgotten something?


Christian_R. Posted on 2003-03-10 18:47:43.0Z
From: Christian_R.
Date: Mon, 10 Mar 2003 13:47:43 -0500
Newsgroups: ianywhere.public.general
Subject: Re: problems with "java in the database"
Message-ID: <A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums>
References: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums> <w#epVAy5CHA.308@forums.sybase.com>
Lines: 80
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub ianywhere.public.general:803
Article PK: 3288

it's asa 7.0 and i use the j2sdk 1.4 for compiling my class.

Source of the Customer:

public class Customer {

public String name;
public String address;
public int zip;

public Customer() {
name="John Doe";
address="unknown address";
zip=0000;
}

public Customer(String name, String address, int zip) {
this.name=name;
this.address=address;
this.zip=zip;
}

public static void classTest() {
System.out.println ("Customer");
}
}

Source of the Product:

public class Product {

public String name ;
public String size ;
public java.math.BigDecimal price ;

public Product () {
price = new java.math.BigDecimal( 0.00 );
name = "unknown name";
size = "unknown size";
}

public Product(String inname, String insize, java.math.BigDecimal
inprice) {
name=inname;
size=insize;
price=inprice;
}

public String toString() {
return size + " " + name + ": " + price.toString();
}

public static void classTest () {
System.out.println( "Product");
}
}

Both files where compiled by the IDE "JCreator" (I tried the "javac
filename.path" command too)

After that I installed the classes with:
install java new from file 'c:\javadb\classes\Customer.class';
install java new from file 'c:\javadb\classes\Product.class';

Then I created two sample tables:
CREATE TABLE customers (
id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
JCust Customer NOT NULL
);

CREATE TABLE products (
id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
JProd Product NOT NULL
);

The insert-command throws an error (ASA 762):
INSERT INTO products(JProd) VALUES(NEW JProd());


I hope this is enough information...


Nick Elson Posted on 2003-03-10 23:18:15.0Z
From: "Nick Elson" <no_spam_nicelson@sybase.com>
References: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums> <w#epVAy5CHA.308@forums.sybase.com> <A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums>
Subject: Re: problems with "java in the database"
Date: Mon, 10 Mar 2003 18:18:15 -0500
Lines: 102
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <D2DTs415CHA.302@forums.sybase.com>
Newsgroups: ianywhere.public.general
NNTP-Posting-Host: 172.31.142.76
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub ianywhere.public.general:805
Article PK: 3278

Okay .... I see the problem.

To make JDK 1.4 generate a class file that is compatable with the ASA JVM
you need to specify

javac -target 1.1 Product.java

when you compile. This is consistent with the original JAVA 2 defintion
but seems to no longer be the default compiland for 1.4.

Using either JDK 1.3.x or 1.2.2 works but will fail the same way if you
specify
a -target higher than 1.1. The difference is those work (by default) if
you
don't specify a -target; with 1.4 you now have to force a target of 1.1.

<Christian_R.> wrote in message
news:A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums...
> it's asa 7.0 and i use the j2sdk 1.4 for compiling my class.
>
> Source of the Customer:
>
> public class Customer {
>
> public String name;
> public String address;
> public int zip;
>
> public Customer() {
> name="John Doe";
> address="unknown address";
> zip=0000;
> }
>
> public Customer(String name, String address, int zip) {
> this.name=name;
> this.address=address;
> this.zip=zip;
> }
>
> public static void classTest() {
> System.out.println ("Customer");
> }
> }
>
> Source of the Product:
>
> public class Product {
>
> public String name ;
> public String size ;
> public java.math.BigDecimal price ;
>
> public Product () {
> price = new java.math.BigDecimal( 0.00 );
> name = "unknown name";
> size = "unknown size";
> }
>
> public Product(String inname, String insize, java.math.BigDecimal
> inprice) {
> name=inname;
> size=insize;
> price=inprice;
> }
>
> public String toString() {
> return size + " " + name + ": " + price.toString();
> }
>
> public static void classTest () {
> System.out.println( "Product");
> }
> }
>
> Both files where compiled by the IDE "JCreator" (I tried the "javac
> filename.path" command too)
>
> After that I installed the classes with:
> install java new from file 'c:\javadb\classes\Customer.class';
> install java new from file 'c:\javadb\classes\Product.class';
>
> Then I created two sample tables:
> CREATE TABLE customers (
> id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
> JCust Customer NOT NULL
> );
>
> CREATE TABLE products (
> id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
> JProd Product NOT NULL
> );
>
> The insert-command throws an error (ASA 762):
> INSERT INTO products(JProd) VALUES(NEW JProd());
>
>
> I hope this is enough information...
>


Christian_R. Posted on 2003-03-11 13:05:35.0Z
From: Christian_R.
Date: Tue, 11 Mar 2003 08:05:35 -0500
Newsgroups: ianywhere.public.general
Subject: Re: problems with "java in the database"
Message-ID: <D35107AE3CB37BD80047EC5A85256CE6.0001737485256CE6@webforums>
References: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums> <w#epVAy5CHA.308@forums.sybase.com> <A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums> <D2DTs415CHA.302@forums.sybase.com>
Lines: 2
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub ianywhere.public.general:807
Article PK: 2747

thank you for your help. now the inserting of new table entries works.
with regards Christian


Nick Elson Posted on 2003-03-10 21:05:23.0Z
From: "Nick Elson" <no_spam_nicelson@sybase.com>
References: <9297C2E73657231C0054DFDF85256CE3.0054DFF585256CE3@webforums> <w#epVAy5CHA.308@forums.sybase.com> <A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums>
Subject: Re: problems with "java in the database"
Date: Mon, 10 Mar 2003 16:05:23 -0500
Lines: 92
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <Cu1Liu05CHA.302@forums.sybase.com>
Newsgroups: ianywhere.public.general
NNTP-Posting-Host: 172.31.142.76
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub ianywhere.public.general:804
Article PK: 3283

The is no class JProd. That should be NEW Product as in

INSERT INTO products(JProd) VALUES(NEW Product());

You may need to prefix Product with the Jar or package name too.

<Christian_R.> wrote in message
news:A80AE1C5B96DA84300673ECC85256CE5.005CBAC285256CE5@webforums...
> it's asa 7.0 and i use the j2sdk 1.4 for compiling my class.
>
> Source of the Customer:
>
> public class Customer {
>
> public String name;
> public String address;
> public int zip;
>
> public Customer() {
> name="John Doe";
> address="unknown address";
> zip=0000;
> }
>
> public Customer(String name, String address, int zip) {
> this.name=name;
> this.address=address;
> this.zip=zip;
> }
>
> public static void classTest() {
> System.out.println ("Customer");
> }
> }
>
> Source of the Product:
>
> public class Product {
>
> public String name ;
> public String size ;
> public java.math.BigDecimal price ;
>
> public Product () {
> price = new java.math.BigDecimal( 0.00 );
> name = "unknown name";
> size = "unknown size";
> }
>
> public Product(String inname, String insize, java.math.BigDecimal
> inprice) {
> name=inname;
> size=insize;
> price=inprice;
> }
>
> public String toString() {
> return size + " " + name + ": " + price.toString();
> }
>
> public static void classTest () {
> System.out.println( "Product");
> }
> }
>
> Both files where compiled by the IDE "JCreator" (I tried the "javac
> filename.path" command too)
>
> After that I installed the classes with:
> install java new from file 'c:\javadb\classes\Customer.class';
> install java new from file 'c:\javadb\classes\Product.class';
>
> Then I created two sample tables:
> CREATE TABLE customers (
> id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
> JCust Customer NOT NULL
> );
>
> CREATE TABLE products (
> id integer DEFAULT AUTOINCREMENT PRIMARY KEY,
> JProd Product NOT NULL
> );
>
> The insert-command throws an error (ASA 762):
> INSERT INTO products(JProd) VALUES(NEW JProd());
>
>
> I hope this is enough information...
>