|
MollyPages.org
"You were wrong case. To live here is to live." |
You can install molly in a location outside of your webserver.unix> export CLASSSPATH=$CLASSPATH:/path/to/molly.jar unix> java fc.jdbc.dbo.GenerateAlternately, you can specify the classpath to the java interpreter:unix> java -cp $CLASSPATH:/path/to/molly.jar java fc.jdbc.dbo.Generate
You can also install molly.jar directly in your web server's WEB-INF/lib directory. (See this for more details).The webserver will automatically add this to it's java classpath. To run programs from the command line, you would say:
unix> export CLASSSPATH=$CLASSPATH:/my/website/WEB-INF/lib/molly.jar unix> java fc.io.HexOutputStreamAlternately, you can specify the classpath to the java interpreter:unix> java -cp CLASSSPATH=$CLASSPATH:/my/website/WEB-INF/lib/molly.jar java fc.io.HexOutputStream
String query = "select * from foo where bar = @bar and baz = @baz";
NamedParamStatement ps = NamedParamStatement.get(con, query);
ps.setString("bar", "hello");
ps.setInt("baz", 42);
This is quite useful for larger, complicated queries with lots
of parameters.
For example, see columns(String) and getFromRS(ResultSet, prefix)
create table users (username varchar(255) primary key, age integer);
Now, we use DBO, generate our java objects and say:
users u = usersMgr.getByKey("molly");
u.set_username("case");
u.set_age(22);
usersMgr.save(con, u);
This would internally create & use a SQL update statement that
would look something like:
UPDATE users set username = 'case', age = '22' where username = 'case';
We update a row using the primary key but we are changing the primary key itself, which
means we can no longer find the original row to update.
This problem is fixed now, by having the generated DBO object internally save the original values of all primary keys. These original values are then used when updating the row. In this example, that would now look like:
UPDATE users set username = 'case', age = '22' where username = 'molly';
Dunno how this elementary bug managed to slip through, undetected for so many years. Primary keys are not changed that often, I guess. Just goes to show that no complex piece of software is ever completely bug free.
With the existence of CommentedFileReader, FilePropertyMgr, IOUtil, StringUtil and Template, using property & configuration files is easy.
JDBCSession.init(..); JDBCSession.someMethod(..);we now say:
JDBCSession session = JDBCSession.getInstance(); //does init if needed session.someMethod();
There is a problem with the command java fc.jdbc.dbo.Generate not printing its usage/help file (due to a java bug with the classloader not being able to load a resource from within a .jar). These usage/help instructions have now been added to the javadoc as well to get around this problem.
I recently pointed the DBO Generator towards a real 400+ table enterprise production database with all sorts of columns, tables and relationships. The generator ran flawlessly and took about 30 seconds to generate and write 800+ classes (2 per table). So the Generator itself is super fast (perhaps the fastest O/R in Java) and does work very nicely.
java.util.Random to WebApp
All molly page users should immediately upgrade to this release.