I am new to Hibernate.
We are migrating one of our existing web application which uses Hibernate 3 and SQL 2000 server to SQL 2005 server.
Can I get help about which version of Hibernate to use with SQL 2005 as I could not find any dialect for SQL 2005 in Hibernate 3.0.5?
Thanks in advance.
I don't believe that the dialect recognizes the difference between SQL Server years; it's all just Microsoft SQL Server.
Which JDBC driver are you using? Microsoft's or jTDS? You only get the features that the driver supports.
And you shouldn't be using database specific features. Your code isn't portable that way.
I am using the standard SQLServer dialect (org.hibernate.dialect.SQLServerDialect) for SQLServer 2005 and I got no issues so far.
I'm using the JTDS JDBC Driver.
I'm also using the Schema Generator, no problems so far.
Related
We are working on the RDBMS Adapter (i.e., to connect to Oracle, MySQL, MSSQL, PostgreSQL, etc) creation. During connecting to Oracle DB we're facing JDBC driver issue for connecting different versions of Oracle Database.
Isn't there any generic driver to connect to what ever the version of Oracle Database it may be?
Like for connecting,
MySQL -> mysql-connector-java
Oracle -> ?
Technology Stack:
Spring Boot
Java 8+ (Planning to go further also)
Angular JS
No, you are supposed to use the right driver for Oracle DB version and Java version. There is no generic driver that fits all combinations e.g. ojdbc6.jar driver does not implement methods introduced in JDBC 4.1+ (Java 7+).
See What are the Oracle JDBC releases versus JDBC specifications? and What are the Oracle JDBC releases versus JDK versions? docs to understand which OJBDC driver you should use.
Have a JavaEE application that is being migrated from Oracle to SQL Server 2016.
Uses Java 1.7, jboss 4.2.3.GA and hibernate 3.2.4.sp1.
The application uses the javax EntityManager for DB access and so queries look like this:
List<ServiceProvider> providers = entityManager
.createQuery("FROM ServiceProvider sp order by sp.id")
.setMaxResults(spCount)
.getResultList();
But a SQL Trace shows the query being wrapped in exec sp_executesql.
For example the above becomes exec sp_executesql N'SELECT TOP (50) ....'
If I trace a query coming from say an SSRS report, it is not wrapped in the sp_executesql.
What is responsible for this transformation?
** edited to a single focused question.
As #MarkRotteveel mentioned in his comment, it seems the MS JDBC driver uses sp_executesql when executing a prepared statement. Once we fixed our missing pool-size and prepared-statement-cache-size options we see no difference between Oracle 12g and SQL Server 2016 so I don't believe there is a performance hit by using sp_executesql or if there it, it is very minimal.
<min-pool-size>20</min-pool-size>
<max-pool-size>220</max-pool-size>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
Interestingly enough, Hibernate executes fewer queries when targeting MSSQL than Oracle. The query in my original post results in 12 Oracle queries vs 10 in MSSQL.
I have an application deployed on Websphere 8.5.5 using an Oracle 12c db connection and I am not able to login to the application. The error I get is:
java.sql.SQLException: Could not commit with auto-commit set on
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4439)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4486)
at oracle.jdbc.OracleConnectionWrapper.commit(OracleConnectionWrapper.java:140)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:1144)
at
Is there a way in Websphere to set this property to false? So far I have tried creating a custom property for the datasources autoCommit = false , type=boolean.
Any ideas? Cheers
There is IBM support page that describe your problem, I hope this help.
IBM support page.
It seems that there is a problem with Oracle 12c drivers.
I was having the same problem here on Websphere Liberty Profile using ojdbc7.jar driver. I've download 11.2.0.3's ojdbc6.jar driver from here, and suddenly, it started working.
we will migrate one application from Oracle 10g to Oracle 11g.
We will not migrate the application Server(WebLogic 10), i would like to know if i need to change the JDBC Version or I can still use the JDBC-Driver from Oracle 10g.
Best Regards
Edney
I am new to Hibernate. While reading Hibernate, I came across the Dialect property. Whatever database we will use in our application, we need to set dialect related to that database and Hibernate will generate appropriate query related to that database.
Just want to know if it is the mandatory property to be set? If it is not and not specified in the hibernate.cfg.xml file, then how will Hibernate generate the SQL queries i.e. which database compliant SQL query will be generated?
No it is not mandatory as per documentation
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html#configuration-optional-dialects
, I had not try with the same. While your answer of others points I will also like to get answer from some good experienced here. :)
I think it's not mandatory but it's a good practice to set it in your hibernate.cfg.xml as
<property name="dialect">your dialect</property>
posible values:
DB2 org.hibernate.dialect.DB2Dialect
DB2 AS/400 org.hibernate.dialect.DB2400Dialect
DB2 OS390 org.hibernate.dialect.DB2390Dialect
PostgreSQL org.hibernate.dialect.PostgreSQLDialect
MySQL org.hibernate.dialect.MySQLDialect
MySQL with InnoDB org.hibernate.dialect.MySQLInnoDBDialect
MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect
Oracle (any version) org.hibernate.dialect.OracleDialect
Oracle 9i org.hibernate.dialect.Oracle9iDialect
Oracle 10g org.hibernate.dialect.Oracle10gDialect
Sybase org.hibernate.dialect.SybaseDialect
Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect
Microsoft SQL Server org.hibernate.dialect.SQLServerDialect
SAP DB org.hibernate.dialect.SAPDBDialect
Informix org.hibernate.dialect.InformixDialect
HypersonicSQL org.hibernate.dialect.HSQLDialect
Ingres org.hibernate.dialect.IngresDialect
Progress org.hibernate.dialect.ProgressDialect
Mckoi SQL org.hibernate.dialect.MckoiDialect
Interbase org.hibernate.dialect.InterbaseDialect
Pointbase org.hibernate.dialect.PointbaseDialect
FrontBase org.hibernate.dialect.FrontbaseDialect
Firebird org.hibernate.dialect.FirebirdDialect
This is why...
You do not need the dialect property if you set up your database connection with hibernate configuration because hibernate does it for you:
hibernate.connection.driver
hibernate.connection.url
user configs and etc...
However, if you set up the connection with regular data source code and use hibernate you need to specify the hibernate.dialect property, because then the connection will not know what hibernate dialect.
dataSource.setdriverClassName
datasource.setUrl...
password configs and etc...