Tag: java

“could not initialize a collection” + @Lob + MSSQL

When using Blob-fields in n-to-m-relations Hibernate and MSSQL are failing for some reason. SQL Error: 421, SQLState: S0001 The image data type cannot be selected as DISTINCT because it is not comparable. … could not initialize a collection: [Dataset.documents#someID] My classes look as follows: @Entity class Dataset { @OneToMany(fetch = FetchType.LAZY) public List<Document> documents = […]

JDBC, INSERT MULTIPLE records obtained from query, into other table

I need to insert multiple records into mysql database at once. What I am doing is SELECT on one table, from my application with Prepared statement. What I must do is to insert those results into one other temporary table. String sqlquery = “select * from table1 where arg1 = ?”; PreparedStatement statement; statement = […]

Issues Connecting Ubuntu 10.4 to MS SQL DB thru Java

What is the best way to allow a Java Application to connect to a MS SQL database in Ubuntu. I am currently trying jTDS but can not seem to get the connection to the server established.

SQL Server Libraries for Java

I’m curious to find what SQL Server libraries are available for Java. At present we are using the com.microsoft.jdbc.sqlserver.SQLServerDriver driver. I think this was downloaded from the Microsoft site a while ago. What alternative libraries are available? Many thanks, Andez

Hibernate JDBCConnectionException: could not update

In a Java + Hibernate aplication, we get a JDBCConnectionException: org.hibernate.exception.JDBCConnectionException: could not update: [net.gencat.cultura.itinerarisLectura.model.AppVariables#14] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2303) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2603) at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at hibernate.util.ManagedSession.rollbackTransaction(ManagedSession.java:64) at net.gencat.cultura.itinerarisLectura.model.home.AppVariablesHome.attachDirty(AppVariablesHome.java:122) at net.gencat.cultura.itinerarisLectura.struts.action.AppVariablesAction.save(AppVariablesAction.java:157) at sun.reflect.GeneratedMethodAccessor1526.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at […]

Representing dates which are a certain number of days before or after another date in a RDBMS

Is there a standard way to represent dates which are a certain number of days before or after another date in an RDBMS? For example, let’s say Date 1 is 30th October, 2005, which can obviously be stored in a datetime column or similar in the RDB. But let’s say Date 2 is “3 days […]

sql stop count at a given threshold

I am generating reports in my system but some reports are returning a huge number of results. To remedy this I hit the database with a count first, then in my code I check if this count is above a certain threshold (e.g. 2000), then don’t generate the report. This is fine in most cases […]

Converting Oracle or Sql Server DDL to Derby

We have SQL Server/Oracle DDL but I’d like to use Derby for development/automated testing purposes. I want a test env that I can sync to from source control and just run – no DB install BS. Does anyone know a good way to convert either SQL Server or Oracle DDL to Apache Derby?

How to make a webservice and connect android application with it

I made an android game. Now i want to store game score of each user in a database. I am not getting how i can do it, but as far as my findings i need to create a web service for it, where all the functionality for fetching and storing of data. My questions are: […]

execution stops with no errors thrown during jdbc connection

Just got done setting everything up and ran my code. but java doesn’t throw any errors so I don’t know what is wrong. Here is my setup win7 – sql server 2008 express r2 – eclipse-everything on one computer(localhost). Here is code: Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); String connectionUrl = “jdbc:sqlserver://localhost:1433;” + “databaseName=MyDatabase;user=sa;password=test;”; System.out.println(“AAA”); Connection conn = DriverManager.getConnection(connectionUrl); System.out.println(“BBB”); […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.