How to Connect Microsoft SQL server in Vert.x (2.1M5) Java 1.8

741 views
Skip to first unread message

Ramesh Srinivasalu

unread,
Mar 26, 2015, 3:05:59 PM3/26/15
to ve...@googlegroups.com
Hi,

Could you please help me on how to Connect Microsoft SQL server in Vert.x (2.1M5) Java 1.8?

Earlier i used below code to connect to Postgresql and it worked but it's not working for MS SQL server.

  container.deployModule("com.bloidonia~mod-jdbc-persistor~2.1.3",pgConfig,
                new AsyncResultHandler<String>() {
                    @Override
                    public void handle(AsyncResult<String> stringAsyncResult) {
                        System.out.println("deploy jdbc persistor module for App Goofy" + stringAsyncResult);
                    }
                });



Json Config:

 "microsoftSQLdbJDBC" : {
        "address" : "MSSQLdbcalleventbus",
        "driver" : "org.postgresql.Driver",
        "url" : "jdbc:microsoft:sqlserver://server01:1433",
        "databasename" : "test"
        "username" : "test",
        "password" : "test3456"
  },

Your input will be greatly appriciated..

Thanks
Ramesh

Tim Yates

unread,
Mar 26, 2015, 3:18:30 PM3/26/15
to ve...@googlegroups.com

What do you mean by "not working"?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ramesh Srinivasalu

unread,
Mar 26, 2015, 3:20:40 PM3/26/15
to ve...@googlegroups.com
I get this error message: Also, I'm not sure whether the code is correct? PLease help me to connect to MS SQL using JDBC persistor..

SEVERE: Error when starting JdbcBusMod
java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at com.bloidonia.vertx.mods.JdbcProcessor.setupPool(JdbcProcessor.java:83)
at com.bloidonia.vertx.mods.JdbcProcessor.start(JdbcProcessor.java:162)
at org.vertx.java.platform.Verticle.start(Verticle.java:82)
at org.vertx.java.platform.impl.DefaultPlatformManager$21.run(DefaultPlatformManager.java:1733)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:175)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)


--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/_oBpeGXP7A0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
With Thanks & Regards,
Ramesh Srinivasalu
Mobile no: 480-685-7096

Tim Yates

unread,
Mar 26, 2015, 3:27:32 PM3/26/15
to ve...@googlegroups.com

I suspect you're not telling us something

You seem to have configured the postgres driver in an attempt to connect to a mssql database connect string, but the error shows your trying to use the hypersonic database driver

Ramesh Srinivasalu

unread,
Mar 26, 2015, 3:36:25 PM3/26/15
to ve...@googlegroups.com
Hi,

Earlier I tried with this driver too
org.hsqldb.jdbcDriver
Even this driver, I'm getting the same error.. Could you help me to specify the correct config details how to connect to Microsoft sql server using JDBC persistor 2.1.2?

Thanks for your help.


Ramesh Srinivasalu

unread,
Mar 26, 2015, 3:42:12 PM3/26/15
to ve...@googlegroups.com

​Please find the attached code TestVert.xMSSQLAPI.zip

Jochen Mader

unread,
Mar 26, 2015, 3:48:41 PM3/26/15
to ve...@googlegroups.com
I really think you should read up on JDBC before actually trying this.
Blindly playing around with driver-names and jdbc-urls won't get you anywhere.

As a hint:
This line instructs the module to use the PostgreSQL-JDBC driver:
"driver" : "org.postgresql.Driver",
You will need to specify the MSSql-Driver here and provide the driver-jar in your classpath.

The following part looks correct as you specify the URL to the server:
 "url" : "jdbc:microsoft:sqlserver://server01:1433",

BUT it won't work, as the PostgreSQL driver won't work with a MSSql-Server.


Cheers,
Jochen
Jochen Mader | Lead IT Consultant

codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de | www.more4fi.de

Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz

Ramesh Srinivasalu

unread,
Mar 26, 2015, 3:48:51 PM3/26/15
to ve...@googlegroups.com, tim....@gmail.com
Hi Tim,

Could you please guide me to the correct Json connecting setting to use Microsoft SQL server as database using mod-JDBC-Persistor. Can we use mod-JBCS-Persistor for Microsoft SQL database ? if so, Could you please point me to the URLs where can I find the sample code using vert.x java and MS SQL?
Your help will be greatly appriciated.

Thanks
Ramesh

Tim Yates

unread,
Mar 26, 2015, 3:52:31 PM3/26/15
to rame...@gmail.com, ve...@googlegroups.com

Never used mssql so I don't have an example.

Set the driver name to the jdbc driver for mssql (not hypersonic, not postgres, but the actual driver for your database)

Make sure the jar containing that driver is on your classpath

It should just work

Jez P

unread,
Mar 26, 2015, 6:23:56 PM3/26/15
to ve...@googlegroups.com, tim....@gmail.com, rame...@gmail.com
As Tim has said more than once,

I'm sure you can use mod-JDBC-persistor for MSSQL but you need to know what driver to use. Every RDBMS which has a JDBC driver will work, but you can't randomly pick out drivers and hope one will work. You need to find a JDBC driver which supports MS SQL, get that into your classpath, and use that driver classname in your JSON.

I suggest starting by trying to find some ordinary non-vertx java code for doing this, and I think things will become clearer to you - there must be lots of examples on the web.

Jez P

unread,
Mar 26, 2015, 6:26:44 PM3/26/15
to ve...@googlegroups.com, tim....@gmail.com, rame...@gmail.com
Reply all
Reply to author
Forward
0 new messages