-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: java.sql.SQLException: No suitable driver executing ant eg
PostPosted: Mon Sep 18, 2006 6:43 am 
Newbie

Joined: Mon Sep 18, 2006 6:34 am
Posts: 18
Hi all,

I've seen this post a few times on the forum and it seems that most people get it sorted by adding the jdbc driver classes to the hibernate lib directory or else including them in the classpath. I've done both and still have no joy running the example.

I'm trying to hook up to a local instance of MS Sql Server and have msbase.jar, mssqlserver.jar and msutil.jar in the hibernate lib folder. I've also added the 3 jar files to the CLASSPATH.

The properties (I've removed all commented entries) and stack trace are below:

Hibernate version: 3.1.3

Mapping documents:
######################
### Query Language ###
######################

## define query language constants / function names

hibernate.query.substitutions yes 'Y', no 'N'



#################
### Platforms ###
#################

## MS SQL Server

hibernate.dialect org.hibernate.dialect.SQLServerDialect
hibernate.connection.username sa
hibernate.connection.password thisishidden
hibernate.connection.url jdbc:microsoft:sqlserver://(local):1433



#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 1



##############################
### Proxool Connection Pool###
##############################

hibernate.proxool.pool_alias pool1



##############################
### Miscellaneous Settings ###
##############################

## format SQL in log and console

hibernate.format_sql true


## set the maximum depth of the outer join fetch tree

hibernate.max_fetch_depth 1



#####################
### JDBC Settings ###
#####################

## enable batch updates even for versioned data

hibernate.jdbc.batch_versioned_data true


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true



##########################
### Second-level Cache ###
##########################

## set a prefix for cache region names

hibernate.cache.region_prefix hibernate.test


## choose a cache implementation

hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
[java] 11:39:09,777 WARN SettingsFactory:103 - Could not obtain connection
metadata
[java] java.sql.SQLException: No suitable driver
[java] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[java] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFacto
ry.java:72)
[java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.j
ava:1881)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
tion.java:1174)
[java] at org.hibernate.auction.Main.main(Main.java:368)
[java] 11:39:09,855 INFO Dialect:103 - Using dialect: org.hibernate.dialec
t.SQLServerDialect
[java] 11:39:09,886 INFO TransactionFactoryFactory:31 - Using default tran
saction strategy (direct JDBC transactions)
[java] 11:39:09,886 INFO TransactionManagerLookupFactory:33 - No Transacti
onManagerLookup configured (in JTA environment, use of read-write or transaction
al second-level cache is not recommended)
[java] 11:39:09,886 INFO SettingsFactory:125 - Automatic flush during befo
reCompletion(): disabled
[java] 11:39:09,917 INFO SettingsFactory:129 - Automatic session close at
end of transaction: disabled
[java] 11:39:09,917 INFO SettingsFactory:144 - Scrollable result sets: dis
abled
[java] 11:39:09,933 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): d
isabled
[java] 11:39:09,933 INFO SettingsFactory:160 - Connection release mode: au
to
[java] 11:39:09,933 INFO SettingsFactory:184 - Maximum outer join fetch de
pth: 1
[java] 11:39:09,933 INFO SettingsFactory:187 - Default batch fetch size: 1

[java] 11:39:09,933 INFO SettingsFactory:191 - Generate SQL with comments:
disabled
[java] 11:39:09,933 INFO SettingsFactory:195 - Order SQL updates by primar
y key: disabled
[java] 11:39:09,949 INFO SettingsFactory:338 - Query translator: org.hiber
nate.hql.ast.ASTQueryTranslatorFactory
[java] 11:39:09,949 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTran
slatorFactory
[java] 11:39:09,964 INFO SettingsFactory:203 - Query language substitution
s: {no='N', yes='Y'}
[java] 11:39:09,964 INFO SettingsFactory:209 - Second-level cache: enabled

[java] 11:39:09,964 INFO SettingsFactory:213 - Query cache: disabled
[java] 11:39:09,964 INFO SettingsFactory:325 - Cache provider: org.hiberna
te.cache.HashtableCacheProvider
[java] 11:39:09,964 INFO SettingsFactory:228 - Optimize cache for minimal
puts: disabled
[java] 11:39:10,042 INFO SettingsFactory:233 - Cache region prefix: hibern
ate.test
[java] 11:39:10,042 INFO SettingsFactory:237 - Structured second-level cac
he entries: disabled
[java] 11:39:10,042 INFO SettingsFactory:264 - Statistics: disabled
[java] 11:39:10,042 INFO SettingsFactory:268 - Deleted entity synthetic id
entifier rollback: disabled
[java] 11:39:10,058 INFO SettingsFactory:283 - Default entity-mode: pojo
[java] 11:39:10,121 INFO SessionFactoryImpl:154 - building session factory

[java] 11:39:10,402 INFO SessionFactoryObjectFactory:82 - Not binding fact
ory to JNDI, no JNDI name configured
[java] 11:39:10,433 INFO SchemaExport:152 - Running hbm2ddl schema export
[java] 11:39:10,433 DEBUG SchemaExport:168 - import file not found: /import
.sql
[java] 11:39:10,433 INFO SchemaExport:177 - exporting generated schema to
database
[java] 11:39:10,433 ERROR SchemaExport:200 - schema export unsuccessful
[java] java.sql.SQLException: No suitable driver
[java] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[java] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[java] at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnecti
onHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:27)
[java] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.
java:178)
[java] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.j
ava:131)
[java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
pl.java:295)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
tion.java:1176)
[java] at org.hibernate.auction.Main.main(Main.java:368)
[java] Setting up some test data
[java] 11:39:10,542 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState
: 08001
[java] org.hibernate.exception.JDBCConnectionException: Cannot open connect
ion
[java] 11:39:10,542 ERROR JDBCExceptionReporter:72 - No suitable driver
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon
verter.java:74)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
tionHelper.java:43)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
tionHelper.java:29)
[java] at org.hibernate.jdbc.ConnectionManager.openConnection(Connectio
nManager.java:420)
[java] at org.hibernate.jdbc.ConnectionManager.getConnection(Connection
Manager.java:144)
[java] at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:12
9)
[java] at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransacti
on.java:57)
[java] at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.j
ava:1290)
[java] at org.hibernate.auction.Main.createTestAuctions(Main.java:285)
[java] at org.hibernate.auction.Main.main(Main.java:370)
[java] Caused by: java.sql.SQLException: No suitable driver
[java] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[java] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[java] at org.hibernate.jdbc.ConnectionManager.openConnection(Connectio
nManager.java:417)
[java] ... 6 more
[java] Exception in thread "main"

BUILD FAILED
file:C:/HIBERN~1.1/build.xml:707: Java returned: 1

Name and version of the database you are using: MS Sql Server 2000

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 8:37 am 
Newbie

Joined: Mon Sep 18, 2006 4:14 am
Posts: 5
maybe you could give 'hibernate.connection.driver_class' property and tell what driver class to use ?

(I haven't used properties files ever so i just guess :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 11:18 am 
Newbie

Joined: Mon Sep 18, 2006 6:34 am
Posts: 18
Yeah, that seemed to clear things up. I also put in the correct JDBC driver class and changed (local) to the server name. The properties file now reads as:

hibernate.dialect org.hibernate.dialect.SQLServerDialect
hibernate.connection.username sa
hibernate.connection.password thisishidden
hibernate.connection.url jdbc:microsoft:sqlserver://servername:1433
hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.