new JDBC support in lift-mapper

23 views
Skip to first unread message

alm4...@gmail.com

unread,
Feb 11, 2009, 3:59:16 PM2/11/09
to Lift
Hi All:

I've added support for Microsoft SQL Server and Oracle 10g JDBC driver
to lift-mapper.
Please test out support for these databases if you can.
Please post about bugs and experiences to this group.

Also, it is useful for us to know if there are other databases you are
seeking support for.

Thanks,
Al

Tim Perrett

unread,
Feb 11, 2009, 6:34:47 PM2/11/09
to Lift
Al,

It would be usefull if you could just post an example of the needed
connection object that people will need to put in boot.scala

Cheers

Tim

Tim Perrett

unread,
Feb 12, 2009, 6:23:02 AM2/12/09
to Lift
Just found a bug with the MSSQL drivers... Looks like its all working
fine, but on boot I see this with the schemifier:

Like I say, it works (the app that is) but having this stack trace on
boot is not nice. Any ideas?

INFO - CREATE TABLE modifiers (name VARCHAR(100) , id BIGINT IDENTITY
NOT NULL , description VARCHAR(200) , weighting BIGINT)
ERROR - Failed to Boot
java.sql.SQLException: There is already an object named 'modifiers' in
the database.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic
(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken
(TdsCore.java:2816)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:
2254)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults
(TdsCore.java:631)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults
(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL
(JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeImpl
(JtdsStatement.java:723)
at net.sourceforge.jtds.jdbc.JtdsStatement.execute
(JtdsStatement.java:1157)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier
$$maybeWrite(Schemifier.scala:150)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier
$$ensureTable(Schemifier.scala:160)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun
$1.apply(Schemifier.scala:60)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun
$1.apply(Schemifier.scala:60)
at scala.List.foldLeft(List.scala:1059)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply
(Schemifier.scala:60)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply
(Schemifier.scala:54)
at net.liftweb.mapper.DB$.use(DB.scala:305)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:
53)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:
36)
at bootstrap.liftweb.Boot.boot(Boot.scala:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply
(ClassHelpers.scala:393)
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply
(ClassHelpers.scala:391)
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply
(LiftRules.scala:905)
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply
(LiftRules.scala:905)
at net.liftweb.util.Full.map(Box.scala:284)
at net.liftweb.http.DefaultBootstrap$.boot(LiftRules.scala:
905)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:569)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:544)
at org.mortbay.jetty.servlet.FilterHolder.doStart
(FilterHolder.java:97)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize
(ServletHandler.java:620)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:
140)
at org.mortbay.jetty.webapp.WebAppContext.startContext
(WebAppContext.java:1233)
at org.mortbay.jetty.handler.ContextHandler.doStart
(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart
(WebAppContext.java:460)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
(Jetty6PluginWebAppContext.java:124)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart
(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart
(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart
(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart
(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start
(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
(AbstractJettyMojo.java:379)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute
(AbstractJettyMojo.java:321)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute
(AbstractJettyRunMojo.java:205)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute
(Jetty6RunMojo.java:184)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo
(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
(DefaultLifecycleExecutor.java:558)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal
(DefaultLifecycleExecutor.java:512)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
(DefaultLifecycleExecutor.java:482)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:330)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:
129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced
(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode
(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

alm4...@gmail.com

unread,
Feb 12, 2009, 9:48:56 AM2/12/09
to Lift
I have some patches to Schemifier that were not ready by the 1.0
freeze.

I tracked this problem down to line 122 of Schemifier.scala:

using(md.getTables(null, getDefaultSchemaName(connection), null,
null)){ rs =>

But an ifdef is obviously not what we want here.

I think I should have put this line at bottom of SqlServerDriver
definition (in Driver.scala):

overrride def defaultSchemaName : Box[String] = Full("dbo")

Specifically,

diff --git a/lift-mapper/src/main/scala/net/liftweb/mapper/
Driver.scala b/lift-mindex 07110f2..27c2ae4 100644
--- a/lift-mapper/src/main/scala/net/liftweb/mapper/Driver.scala
+++ b/lift-mapper/src/main/scala/net/liftweb/mapper/Driver.scala
@@ -169,7 +169,7 @@ object SqlServerDriver extends DriverType
("Microsoft SQL Ser def longColumnType = "BIGINT"
def doubleColumnType = "FLOAT"

- //override def defaultSchemaName : Box[String] = Full("dbo")
+ override def defaultSchemaName : Box[String] = Full("dbo")
}

object OracleDriver extends DriverType("Oracle") {


I see a NPE fail at ensureIndexes in Schemifier in the lift-mapper
tests after this delta.
I'll post a fix for this as soon as I have it. I will commit these
fixes as soon as I get a chance.

Regards,
Al

alm4...@gmail.com

unread,
Feb 12, 2009, 11:37:30 AM2/12/09
to Lift
The defaultSchemaName fix for the SqlServerDriver is checked in.
Please let me know if that fixes the startup stacktrace you were
seeing.

Tim Perrett

unread,
Feb 12, 2009, 3:02:03 PM2/12/09
to Lift
Hey Al,

Im afraid not - now I get this on boot:

java.lang.NullPointerException
at net.liftweb.mapper.Schemifier$$anonfun$8.quad$1
(Schemifier.scala:233)
at net.liftweb.mapper.Schemifier$$anonfun$8.apply
(Schemifier.scala:237)
at net.liftweb.mapper.Schemifier$$anonfun$8.apply
(Schemifier.scala:229)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier
$$using(Schemifier.scala:45)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier
$$ensureIndexes(Schemifier.scala:229)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun
$3.apply(Schemifier.scala:62)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun
$3.apply(Schemifier.scala:62)
at scala.List.foldLeft(List.scala:1059)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply
(Schemifier.scala:62)

Tim Perrett

unread,
Feb 19, 2009, 1:39:18 PM2/19/09
to Lift
Just to update this thread - Derek has been a super star and fixed the
schemifier so now it doesn't bone on application boot. Result.

Thanks Derek.

Tim
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFai lures
> (DefaultLifecycleExecutor.java:330)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
> (DefaultLifecycleExecutor.java:291)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
> (DefaultLifecycleExecutor.java:142)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
> 336)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:
> 129)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke
> (NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.codehaus.classworlds.Launcher.launchEnhanced
> (Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at org.codehaus.classworlds.Launcher.mainWithExitCode
> (Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>
> ...
>
> read more »

David Pollak

unread,
Feb 19, 2009, 1:40:48 PM2/19/09
to lif...@googlegroups.com
On Thu, Feb 19, 2009 at 10:39 AM, Tim Perrett <he...@timperrett.com> wrote:

Just to update this thread - Derek has been a super star and fixed the
schemifier so now it doesn't bone on application boot. Result.

Thanks Derek.

Rock on Derek!
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Derek Chen-Becker

unread,
Feb 19, 2009, 1:45:04 PM2/19/09
to lif...@googlegroups.com
Glad I could help!
Reply all
Reply to author
Forward
0 new messages