View Feed
group-icon
Java Developers
Community of Java Developers: Get Java Programming Help from fellow Java Developers across the world.
562 Members
Join this group to post and comment.
ankur8819
ankur8819 • Jan 23, 2012

Executing java file from DB

Hi everyone,
I am not sure how logical my question is but it struck me so here I am.
For a application whose logic changes frequently, the problem with keeping the application up becomes a problem as there have to be a lot of deployments to keep the logic up to date.
Is it possible to store a Java file into DB and then at create its class at runtime and have it run on the Application Server.
I think we can store --> retrive---> and make an object of class at run time using normal sql queries and Reflections in Java but I am not sure how will it will behave when it runs on the App Server.
Anyone implemented such case.??
If yes ,is it advisable to go via this approach.What could be the pros and cons .
Thanks ,
Ankur
sookie
sookie • Jan 23, 2012
Hi ankur,

I liked the idea..very useful where applications take lot of time to start. But I couldn't get one thing if you want to save .class file or .java file to save the time.

I guess this is achievable, I haven't given a try but you can save the file as CLOB data type in database and change the deployment script/build script where you mention your .java/.class files path, you need to work hard bit on this thing. Retrieving the file from DB at run time or whatever is the requirement. Let us know if any issues.
Anoop Kumar
Anoop Kumar • Jan 23, 2012
when you are running a web/application server . server builds whole application that means server context is aware of every class file/file with compile timestamp before starting a application.you are asking for storing .class file in database retrieve it --> save in build path --> and use a reflections.
I think it's not going to work.
for try : configure a web project with tomcat and run it , As soon as you save the any java file context will be reloaded.
On the other way you can store logic in database or properties files.
If you elaborate you problem we can try some solution.😀
I guess storing the scripts inside database and executing them is not a good idea. In that case, you go into a issue of executing a vulnerable script from the database and there might be loop holes and possiblities are that your script and databases might be misused or compromised.
K!r@nS!ngu
K!r@nS!ngu • Jan 24, 2012
ankur8819
Is it possible to store a Java file into DB and then at create its class at runtime and have it run on the Application Server.
I am not sure whether it is possible or not but i admire you for the creative idea. I guess we can store Java files but running it should be done after retrieving it to the separate folder from DB.

Anyways let me give a try...

Share this content on your social channels -