473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Executing Java methods from database

Hi,

I want to store particular algorithms written in Java into a database
(preferably MySQL) and then be able to accept values such as algorithm
type and parameters from a user (via JDBC) which will select the
algorithm from the database, excecute it and return the result. I
understand that MySQL does not support Java object types, so does
anybody have any suggestions on how I could implement this? Will I
need to compile the code and then store this into my database?

Thanks a lot

Paul

Mar 2 '06 #1
1 1378
"Paul" <Pa**********@googlemail.com> wrote in message
news:11*********************@e56g2000cwe.googlegro ups.com...
I want to store particular algorithms written in Java into a database
(preferably MySQL) and then be able to accept values such as algorithm
type and parameters from a user (via JDBC) which will select the
algorithm from the database, excecute it and return the result. I
understand that MySQL does not support Java object types, so does
anybody have any suggestions on how I could implement this? Will I
need to compile the code and then store this into my database?


You're talking about serializing a Java class, as opposed to an object. As
far as I know, Java doesn't support serializing classes. You can serialize
an object, that is an instance of a class. Then you can deserialize the
object and instantiate it -- if its class is on your classpath. But Java
doesn't support serializing/deserializing the class itself.

You could convert the compiled Java bytecode for the class into a byte[]
array and store that, but then once you retrieve it, you'd have to write a
custom classloader to get that class into your JVM. See Jiapi
(http://jiapi.sourceforge.net/) or ObjectWeb ASM (http://asm.objectweb.org/)
which might do what you need.

Alternately, one could use BeanShell (http://www.beanshell.org/) instead of
pure Java to implement the algorithms. One could store the BeanShell script
in the database as text, retrieve it with JDBC, and execute it using the
eval() method of class bsh.Interpreter
(http://www.beanshell.org/javadoc/bsh/Interpreter.html).

Regards,
Bill K.
Mar 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
15
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
1
by: jesmi | last post by:
my code is: U]employee.cfm <html> <head> <title>Employee List</title> </head> <body> <h1>Employee List</h1>
0
by: mamoon | last post by:
hi all, i am facing a serious problem in running JDBC programm in Apache server environment. Background Information- 1, OS: Enterprise Linux4 running Apache2 2. pgsql8.2 3.JDBC driver:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.