Re: Java code generation from sql



"Oliver Wong" <owong@xxxxxxxxxxxxxx> writes:

"Remi" <remi.roques@xxxxxxxxx> wrote in message
news:1149751500.241078.171210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am working on a simulator in Java. All the parameters of the
simulator are stored in a SQL databse (a priori). The idea would be to
generate java code (.java files) from this databse in order to compile
the simulator afterwards and have an application running without the
database (faster I think).
Do you have any idea about a tool doing that or how the create a java
code generation from a database (sql or not) ?

Have you considered using a bunch of println(); statements to emit
a .java file? E.g.

fileOut.println("public class Test() { System.out.println(\"Hello
World!\"); }");

It's the most direct and simplest solution. If it's too simplistic
for you, you might want to investigate JET templates from Eclipse.

Maybe I don't understand what the OP is asking, but why can't you create
a simulation "harness" that that uses interfaces for the parts of the
simulation that depend on parameters from your database?

You can then provide various implementations for these interfaces to
control your simulation.

You can still keep the config paramters in a database. Just query the
parameters from the database when you start your simulation and feed
the parameters to factories that return the correct implementations
for this simulation. If need be, you could store the name of the
implementation in the database and use reflection to instantiate it.

When this step has completed your simulation would run without any
interaction with the database.

I think this would be both easier and faster than fetching actual java
source code out of a db and try to assemble it into something that you
can compile...

--
dt

.



Relevant Pages

  • Re: Ingenieurmangel: Nur Gerede oder ist was dran?
    ... mit Spielerein, die keiner braucht, in Java aber schnell ... Die zweite Fraktion war eine Reihe von Studis, die Code bestehend aus Tcl/Tk, Java und shell und Perl und viell. ... ....das NEUE war jedenfalls Bullshit und das Projekt wurde nicht realisiert. ... Es sollte eine Simulation werden, ...
    (de.sci.electronics)
  • Re: Most SF headline of the day
    ... Java doesn't seem to be working right on the system I'm on ... Programming on digital computers is subject to rounding ... Unless done in cooperation among experts in simulation ... And I *certainly* wouldn't trust one done in Java. ...
    (rec.arts.sf.written)
  • Re: help needed on time-dependent functions!
    ... I know a little bit about Java. ... say one second as a single time ... > assignments (a la simulation), ... and learn how to write a for loop (or ...
    (comp.lang.java.help)
  • Re: How many users of Octave and Scilab are there?
    ... I use Scilab all the time. ... I stopped using Simulink the second time I had a big simulation break ... The debugging has gotten miles better in recent versions, ... I didn't notice the migration to Java. ...
    (sci.engr.control)
  • Re: Physics simulation framework
    ... > I'm looking for some physics simulation framework for Java beginners. ... > It would be also great to be able to program behavour of some items. ...
    (comp.lang.java.programmer)