Erro ao me conectar no FireBird+Hibernate

3 respostas
paulofafism

Pessoal porque esta acontecendo esse erro na hora que me conecto no FireBird. O CLASSPATH esta configurado corretamente, o que pode ser este erro/?

Informações do erro
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" java.lang.UnsatisfiedLinkError: no jaybird21 in java.library.path
       at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
       at java.lang.Runtime.loadLibrary0(Runtime.java:823)
       at java.lang.System.loadLibrary(System.java:1030)
       at org.firebirdsql.gds.impl.jni.JniGDSImpl.initJNIBridge(JniGDSImpl.java:56)
       at org.firebirdsql.gds.impl.jni.JniGDSImpl.<clinit>(JniGDSImpl.java:21)
       at org.firebirdsql.gds.impl.jni.LocalGDSFactoryPlugin.getGDS(LocalGDSFactoryPlugin.java:40)
       at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:219)
       at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:110)
       at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:125)
       at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
       at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
       at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
       at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
       at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
       at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
       at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
       at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" java.lang.NoClassDefFoundError: Could not initialize class org.firebirdsql.gds.impl.jni.LocalGDSImpl
       at org.firebirdsql.gds.impl.jni.LocalGDSFactoryPlugin.getGDS(LocalGDSFactoryPlugin.java:40)
       at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:219)
       at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:110)
       at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:125)
       at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
       at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
       at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
       at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
       at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
       at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
       at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
       at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
//Configuração do arquivo de mapeamento do hibernate
<!DOCTYPE hibernate-configuration PUBLIC
	"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
	<session-factory>
                <property name="connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
                <property name="connection.url">jdbc:firebirdsql:local:/C:\\Teste.fdb</property>
                <property name="connection.username">SYSDBA</property>
                <property name="connection.password">masterkey</property>
                <property name="dialect">org.hibernate.dialect.FirebirdDialect</property>       

		
		<!-- Condiguração do c3p0 -->
		
		<property name="hibernate.c3p0.max_size">10</property>
		<property name="hibernate.c3p0.min_size">2</property>
		<property name="hibernate.c3p0.timeout">5000</property>		
		<property name="hibernate.c3p0.max_statements">10</property>
		<property name="hibernate.c3p0.idle_test_period">3000</property>
		<property name="hibernate.c3p0.acquire_increment">2</property>			

		<!-- Configurações de debug -->

		<property name="show_sql">true</property>
                <property name="use_outer_join">true</property>	
                <property name="hibernate.generate_statistics">true</property>
                <property name="hibernate.use_sql_comments">true</property>
        	
		
		
			
	</session-factory>
</hibernate-configuration>

3 Respostas

fsquadro

Paulo,

Pela mensagem ele parece não estar encontrando a library jaybird21. Você conferiu se ela está no CLASSPATH?

paulofafism

Eu consegui resolver o problema, foi erro meu não ler a documentação do FireBird. O problema ocorre e que o arquivo jaybird21 e usado com a versão do JDBC Tipo 2 ou seja não e JDBC Puro. Para usar o JDBC pura teria que usar a seguinte URL:

Pure Java jdbc:firebirdsql:host[/port]:/path/to/db.fdb jdbc:firebirdsql://host[:port]/path/to/db.fdb

Veja abaixo a documentação do FireBird para configurar usando JDBC tipo 2

Configuring Type 2 JDBC driver Type 2 JDBC driver requires JNI library to be installed and available for Java Virtual Machine. Precompiled binaries for Windows and Linux platforms are distributed with Jaybird: Please note that Jaybird 2.1 provides update to the JNI libraries to support new features. It is not compatible with JNI library for Jaybird 2.0. ? jaybird21.dll is precompiled binary for Windows platform. Successfully tested with Windows 2000 and Windows XP SP1, but there should be no issues also in other Win32 OS. Library should be either copied into the directory specified in %PATH% environment variable, or made available to JVM using the java.library.path system property. ? libjaybird21.so is precompiled binary for Linux platform. It must be available via the LD_LIBRARY_PATH environment variable, e.g. copied into /usr/lib/ directory. Another possibility is to specify path to the directory with Jaybird JNI library in java.library.path system property during the JVM startup. ? Other platforms can easily compile the JNI library by checking out the Jaybird sources from the CVS and using ?./build.sh compile-native? command in the directory with checked out sources. After making Jaybird JNI library available to the JVM application has to tell driver to start using this by either specifying TYPE2 or LOCAL type in the connection pool or data source properties or using appropriate JDBC URL when connecting via java.sql.DriverManager.

F

Dae cara blz?

Estou com este problema, poderia me explicar melhor como você fez isso?

Vlw.

Criado 23 de abril de 2007
Ultima resposta 30 de jul. de 2010
Respostas 3
Participantes 3