Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection URl for SQLExpress database using Hibernate

I am using jtds drivers to connect to SQL Server on local using Hibernate

I can conect to server using server name: COMP6\SQLEXPRESS

Below is my connection properties in hibernate.cfg

<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

    <property name="hibernate.connection.url">jdbc:jtds:sqlserver://COMP6\\SQLEXPRESS/ipms_m1_new_final_1apr</property>

    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password">xxxx</property>

Whole stacktrace

java.sql.SQLException: Unknown server host name 'COMP6\\SQLEXPRESS'.
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:401)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at com.nextenders.facadeimplementation.hibernate.util.HibernateFactory.configureSessionFactory(HibernateFactory.java:103)
at com.nextenders.facadeimplementation.hibernate.util.HibernateFactory.buildIfNeeded(HibernateFactory.java:40)
at com.nextenders.facadeimplementation.model.dao.AbstractDao.<init>(AbstractDao.java:19)
at com.nextenders.facadeimplementation.model.dao.domain.common.ConfigurationDao.<init>(ConfigurationDao.java:28)
at com.nextenders.facadeimplementation.facade.domain.common.ConfigurationFacade.getConfigurationList(ConfigurationFacade.java:83)
at com.nextenders.server.businessdelegates.domain.common.ConfigurationBusinessDelegate.getConfigurationList(ConfigurationBusinessDelegate.java:45)
at com.nextenders.server.actions.common.ContextListener.contextInitialized(ContextListener.java:60)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:447)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
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:39)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:543)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:421)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1035)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:783)
at com.google.gwt.dev.DevMode.main(DevMode.java:275)
Caused by: java.net.UnknownHostException: COMP6\\SQLEXPRESS
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:525)
    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:597)
    at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
    at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
like image 685
Hardik Mishra Avatar asked Oct 12 '22 08:10

Hardik Mishra


1 Answers

are you able to connect sqlserver database via telnet using port like : telnet localhost 1433 ??

If yes then

jdbc:jtds:sqlserver://localhost/ipms_m1_new_final_1apr

Hope this helps.

like image 155
Ashfak Balooch Avatar answered Nov 16 '22 09:11

Ashfak Balooch