awferreira / c5-db-migration

Automatically exported from code.google.com/p/c5-db-migration
0 stars 0 forks source link

SQL Server 2005 JDBC URL not handled #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello

I tried to create a SQL Server 2005 database using db-migration version 0.9.7. 
I noticed that SQL Server _2005_ JDBC URLs are not handled.

Running "mvn db-migration:create" does not create the db but raises a
NullPointerException.
Below the stack trace.

mvn -e db-migration:create
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'db-migration'.
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject
[INFO]    task-segment: [db-migration:create]
[INFO] ------------------------------------------------------------------------
[INFO] [db-migration:create]
[INFO] Creating database jdbc:sqlserver://hostname:1515;DatabaseName=testdb.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to create database
jdbc:sqlserver://hostname:1515;DatabaseName=testdb

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to create
database jdbc:sqlserver://hostname:1515;DatabaseName=testdb
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycl
eExecutor.java:583)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(Defaul
tLifecycleExecutor.java:512)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycle
Executor.java:482)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:330)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultL
ifecycleExecutor.java:291)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExec
utor.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.jav
a:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create
database jdbc:sqlserver://hostname:1515;DatabaseName=testdb
        at
com.carbonfive.db.migration.maven.CreateMojo.executeMojo(CreateMojo.java:23)
        at
com.carbonfive.db.migration.maven.AbstractMigrationMojo.execute(AbstractMigratio
nMojo.java:91)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.ja
va:451)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycl
eExecutor.java:558)
        ... 16 more
Caused by: java.lang.NullPointerException
        at
com.carbonfive.db.jdbc.schema.AbstractSchemaCommand.execute(AbstractSchemaComman
d.java:63)
        at
com.carbonfive.db.jdbc.schema.CreateDatabase.execute(CreateDatabase.java:5)
        at
com.carbonfive.db.migration.maven.CreateMojo.executeMojo(CreateMojo.java:19)
        ... 19 more

Regards.
Eric.

Original issue reported on code.google.com by alforic@gmail.com on 18 Mar 2009 at 2:17

GoogleCodeExporter commented 8 years ago
It seems to me that com.carbonfive.db.jdbc.DatabaseUtils does not extract 
correctly
the database name nor the server URL.

Here attached is an attempt tp patch com.carbonfive.db.jdbc.DatabaseUtils.
I basically modified extractDatabaseName(String url) extractServerUrl(String 
url) to
make them handle SQL Server 2005 URLs.

Original comment by alforic@gmail.com on 18 Mar 2009 at 2:31

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the ticket, I'll get to this one soon... hopefully in the next few 
days
when my other project is a little less hectic.  Keep an eye out for a snapshot 
with
the fix.

Original comment by christia...@gmail.com on 20 Mar 2009 at 4:17

GoogleCodeExporter commented 8 years ago

Original comment by christia...@gmail.com on 20 Mar 2009 at 4:17

GoogleCodeExporter commented 8 years ago
I ran into this issue 6 months ago and formulated this patch which has been 
working
well for us.

It addresses several issues including the URL handling but also correct default
drop/create for MSSql server.

Not sure if it will meet your standards but feel free to use/modify or what 
ever.

I am willing to test the fix when you submit it so let me know :-)

Original comment by llin...@gmail.com on 14 May 2009 at 3:15

Attachments:

GoogleCodeExporter commented 8 years ago
Hmmm seems Google is being fancy... I wasn't trying to reference issue 6!

Original comment by llin...@gmail.com on 14 May 2009 at 3:17