Firebird and Hibernate - How do you specify a DB role? - java

I'm working in a new project to convert our Delphi + Firebird system to Java 8 / JavaFX / JPA (Hibernate) and Firebird. We are using the latest version of Jaybird and connecting to Firebird 1.5, Firebird 3.0 and InterBase XE3 databases. I have not found any documentation on connecting to the DB specifying a DB role. Is there a way to do this?

To specify the user role, you need to specify the roleName property in the connection string. See also Extended connection properties in Jaybird JDBC Driver Java Programmer's Manual.
Example of a connection string:
jdbc:firebirdsql://localhost/database?charSet=UTF-8&roleName=myrole

Related

Mapping between DB2 XML CLOB data type and DB2 JDBC types are keep changing as upgrading to different JDBC versions

We were using com.ibm.db2.jcc.db2jcc4 v10.1 and recently we have upgraded it with the V11.1.4 FP5 driver for the z/OS Db2 systems. When we were using com.ibm.db2.jcc.db2jcc4 v10.1 the equivalent JDBC java class for DB2 XML CLOB was com.ibm.db2.jcc.am.ne and now after upgrading it with V11.1.4 FP5 driver now, it changed to com.ibm.db2.jcc.am.db. However in latest version v11.5 M7 FP0 it's again changed to com.ibm.db2.jcc.am.dc.
The question is: If someone using extracting the old DB2 XML CLOB data type from newer JDBC driver then how can we extract an older clob instance which might represents as com.ibm.db2.jcc.am.ne from new V11.1.4 FP5 driver as this has been replaced with com.ibm.db2.jcc.am.db.
It's always better to use the java.sql.SQLXML data type as described at the XML data retrieval in JDBC applications link instead of direct use of these internal driver classes.

What is the MariaDB dialect class name for Hibernate?

In Hibenate I am using MariaDB but I couldn't find the dialect class name of MariaDB .
In Hibernate, MySQL5 dialect's name is
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
For Oracle 10g
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
What is the dialect class name for MariaDB?
Very short answer
The current dialects as of this writing are:
org.hibernate.dialect.MariaDB102Dialect for MariaDB server 10.2
org.hibernate.dialect.MariaDB103Dialect for MariaDB server 10.3 and later, provides sequence support.
org.hibernate.dialect.MariaDB10Dialect for MariaDB server 10.0 and 10.1
org.hibernate.dialect.MariaDB53Dialect for MariaDB server 5.3, and later 5.x versions.
org.hibernate.dialect.MariaDBDialect for MariaDB server 5.1 and 5.2.
Short answer
When using a MariaDB server, you should use MariaDB Connector/J and MariaDB Hibernate dialects, not the MySQL ones. Even though MariaDB was created as a drop-in replacement and even though basic features will likely work when using the MySQL versions of those, subtle problems may occur or you may miss certain features.
A complete list of available MariaDB dialects are currently not mentioned in the Hibernate User Guide, but in the Hibernate JavaDoc. Depending on your MariaDB server version, you should select the corresponding dialect version. The current dialects as of this writing are:
org.hibernate.dialect.MariaDB102Dialect for MariaDB server 10.2
org.hibernate.dialect.MariaDB103Dialect for MariaDB server 10.3 and later, provides sequence support.
org.hibernate.dialect.MariaDB10Dialect for MariaDB server 10.0 and 10.1
org.hibernate.dialect.MariaDB53Dialect for MariaDB server 5.3, and later 5.x versions.
org.hibernate.dialect.MariaDBDialect for MariaDB server 5.1 and 5.2.
Note that for detailed usage information, you'll sometimes have to look in dialect source codes. (There are non-JavaDoc usage information comments in some dialect sources.)
If you want to change or explicitly mention the storage engine for the MariaDB dialect, you can use the storage_engine Hibernate variable. For example: hibernate.dialect.storage_engine = innodb. IMO, you should do this explicitly, because the default can change when switching to a different MariaDB server version.
If you're using a MariaDB server older than 10.1.2 (which doesn't support fractional seconds), then you may want to provide the parameter useFractionalSeconds=false to the JDBC URL, otherwise MariaDB Connector/J will not truncate timestamps internally, which can cause time comparison problem when those values are using in comparison queries (even when using plain JDBC), which can cause Hibernate versioning problems and optimistic locking problems for temporal types.
Long answer
The MariaDB dialect for Hibernate (5.3 as of this writing) is mentioned in the Hibernate User Guide. The mentioned dialect "short names" followed by remarks are:
MariaDB: Support for the MariadB database. May work with newer versions
MariaDB53: Support for the MariadB database, version 5.3 and newer.
However, a complete list of the available official MariaDB dialects can be found in the Hibernate JavaDoc. Which currently lists:
org.hibernate.dialect.MariaDB102Dialect for MariaDB server 10.2
org.hibernate.dialect.MariaDB103Dialect for MariaDB server 10.3 and later, provides sequence support.
org.hibernate.dialect.MariaDB10Dialect for MariaDB server 10.0 and 10.1
org.hibernate.dialect.MariaDB53Dialect for MariaDB server 5.3, and later 5.x versions.
org.hibernate.dialect.MariaDBDialect for MariaDB server 5.1 and 5.2.
Each dialect successor inherits the settings from the previous dialect version. So the inheritance hierachy for MariaDB is: MariaDB103Dialect > MariaDB102Dialect > MariaDB10Dialect > MariaDB53Dialect > MariaDBDialect > MySQL5Dialect > MySQLDialect > Dialect
MariaDB was designed as a drop-in replacement for MySQL. But the databases are likely going to diverge as time goes by. Most basic features probably work without problems, allowing you to swap Connector/J clients (MariaDB client on MySQL server and vice versa), and allow you to swap dialects (MySQL dialect on MariaDB client and vice versa). But there are subtle differences that may cause unexpected problems. For example, the MySQL Connector/J client contains hardcoded checks for the server version, which will fail when using a MariaDB server, causing some features to be disabled in the client, such as the MySQL sendFractionalSeconds client parameter. This will cause fractional seconds to be disabled, so then the fractions will be truncated in the MySQL client but not in the MariaDB client. (This may even lead to optimistic locking problems when using versioning with date/time types in combination with non-max precision SQL date/time types. In these cases, use the max precision of 6.)
Also, the MariaDB dialect are expected to provide specific functionality for MariaDB:
http://in.relation.to/2017/02/16/mariadb-dialects/
In time, we will add new Dialects based on newer capabilities
introduced by MariaDB.
...
If you are using MariaDB, it’s best to use the MariaDB-specific
Dialects from now on since it’s much easier to match the MariaDB
version with its appropriate Hibernate Dialect.
And https://hibernate.atlassian.net/browse/HHH-11457 says:
since MySQL and MariaDB have gone in different directions, we might
want to provide MariaDB Dialects as well.
For instance, it's not very intuitive for a Hibernate user to figure
out that they need to use the MySQLInnoDb57Dialect to handle
Timestamps with microsecond precision which have been available since
MariaDB 5.3:
The Hibernate User Guide doesn't provide all usage information about how to use the dialects. Even the User Guide combines with the API docs may not be enough. Sometimes you'll have to look in the source codes for usage information. For example, MariaDB53Dialect.java contains hidden non-JavaDoc comments that may be useful.
Previously, to select a MySQL storage engine, such as MyISAM or InnoDB or default, you could switch between for example MySQL57InnoDBDialect and MySQL57Dialect. But they refactored the MySQL dialect hierarchy starting from Hibernate 5.2.8, as mentioned in a Hibernate blog post. Note that to select a storage engine, you should use a Environment Variable or System Property: hibernate.dialect.storage_engine. For example: hibernate.dialect.storage_engine = innodb.
XtraDB was the default MariaDB storage engine for MariaDB 10.1 and earlier, but since 10.2 it's InnoDB. So there may be cases that you want to explicitly mention the storage engine that Hibernate selects, so then you'll have to use the storage_engine variable. Info about the storage_engine variable (which isn't mentioned in the User Guide), can be found in the source of AvailableSettings.java.
If you're using a MariaDB server older than 10.1.2 (which doesn't support fractional seconds), then you may want to provide the parameter useFractionalSeconds=false to the JDBC URL, otherwise MariaDB Connector/J will not truncate timestamps internally, which can cause time comparison problem, which can cause Hibernate versioning problems and optimistic locking problems for temporal types.
As announced here, starting with Hibernate ORM 5.2.8 (around Feb 15, 2017), the dialects
org.hibernate.dialect.MariaDB53Dialect
and
org.hibernate.dialect.MariaDBDialect
are available. The announcement concludes that
If you are using MariaDB, it’s best to use the MariaDB-specific
Dialects from now on since it’s much easier to match the MariaDB
version with its appropriate Hibernate Dialect.
From here, it was mentioned
"it needs to be the MySQL5InnoDBDialect or MySQL57InnoDBDialect instead of the MySQLInnoDBDialect"
For complete list, see
http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#database-dialect
New MariaDB dialect is added in 5.2.17. See JIRA and commit
You should use the Mysql5Dialect, because MariaDB is compatible with mysql.
https://mariadb.com/kb/en/mariadb-vs-mysql-compatibility/#incompatibilities-between-mariadb-55-and-mysql-55

Is weblogic 81.(SP6) compatible with oracle 11 G and Jdk 1.4.2

I need suggestions/help on the issue below:
I am working on oracle migration work for a Java web application. I want to move my application from oracle 9i to 11g
The environment is :
Jdk – 1.4.2
Weblogic 8.1(SP6)
Database to connect to – Oracle 11g
weblogic.db.url=jdbc:oracle:thin:#${weblogic.db.host}:${weblogic.db.port}/
weblogic.db.driver=oracle.jdbc.OracleDriver
Oracle JDBC Driver version - "10.2.0.2.0"
When I query any table that has a CLOB datatype , the query fails to execute with the following error:
“Cannot assign value of type 'weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB' to property 'description_en' of type 'oracle.sql.CLOB'”.
I have read in oracle docs that weblogic 8.1(S6) supports oracle 11g .
Any other query which returns other than CLOB data type, it works fine, the issue is only with CLOB datatype that too with Oracle 11g :(
The same code works fine if it is connected to Oracle 9i, the only problem is with Oracle 11g.
My assumption is that I may be missing some extra wrappers/extensions which may be needed to map the CLOB datatype as I think there is no direct support from weblogic 8.1.
I also am thinking on below lines:
If the application includes its own Oracle jar file so is not using the data source provided by WebLogic. But I do not know on how should I ascertain this.
Please help!
You need to upgrade your Java version. Java 1.4 is not supported by modern Oracle drivers.
Also, it is best practice to add the Oracle driver jars to the container classpath, and not include them in your application. Then the application needs to reference a datasource provided by the container. If you plan some Oracle-specific fireworks, you may need the driver jars at compile time. You need to mark them as "provided" in your Maven pom.xml.

Driver name for derby 10.7 in-memory

Can any one tell the driver name for derby 10.7 in memory mode?
We are using below for in-memory:
org.apache.derby.jdbc.EmbeddedDriver
and below for filesystem based (for previous derby version):
org.apache.derby.jdbc.ClientDriver
I found that for 10.7 , file-system based, driver name should be:
org.hibernate.dialect.DerbyTenSevenDialect
So is there any change for in-memory driver name?
You can access an in-memory database via the embedded driver or the network driver if the in-memory db is exposed to the network. You have to specify the JDBC connection URL correctly though.
http://db.apache.org/derby/docs/10.11/devguide/cdevdvlpinmemdb.html
I don't understand your terminology. Derby has two different environments in which it can run: Embedded, and Client/Server. See: http://db.apache.org/derby/docs/10.8/getstart/cgsquck70629.html
The JDBC driver names that you have (EmbeddedDriver and ClientDriver) are correct. http://db.apache.org/derby/docs/10.8/getstart/rgsquck35368.html
It looks like you are including Hibernate in your application, as DerbyTenSevenDialect is a Hibernate class, not a Derby class. You need to consult the Hibernate community and documentation for Hibernate information.

mapping database link(drda) tables to entites in jpa

I'm using a oracle thin driver to connect to my database.My database links to another db(DB2) with drda specification.My problem is that I can only view the local tables of my database and map them using jpa but I select from drda in sqldeveloper and it works so the problem is definitely with my application development.What do you think is missing?
my application characteristics are as follows:
IDE: MyEclipse 6.5
Struts
Spring 2.5/JPA
Oracle 10g
Tomcat 6.x
Do I need to specify a jta-data-source? Right now I'm not using a data source?
please help me
Just make sure you have followed these steps given by Oracle.

Categories