Tag: java

How determine database server IP via UDP in Java

I am writing clients in Java that store the data on a database server. So far, the IP and Port of the server has to be specified in the client’s settings manually. I have heard, that it is possible to automatically determine the IP of database servers via broadcast / multicast / UDP (I am […]

JTDS Driver: Could not find a Java charset equivalent to collation 2C04D01000

Looking a solution for strange JTDS error message: Could not find a Java charset equivalent to collation 2C04D01000. I tried to pass file.encoding and user.encoding parameters without any success.

How to fix error: No more data available to read

My java application does use DB Connection pooling. One of the functionality started failing today with this error: [BEA][SQLServer JDBC Driver]No more data available to read This doesn’t occur daily. Once I restart my application server things look fine for some days and this error comes back again. Anyone encountered this error? Reasons might vary, […]

Application not running on 64 bit machine

I am woking on Windows Server 2008 r2. I have installed 32-bit MS SQL Server Express Edition, and the 32-bit JDK and JRE. After I create the DSN to connect to the database (using 32 bit ODBC) and run my JAP application, the following error is displayed: Architecture mismatch between DSN and application.

jdbc sql server error: java.sql.SQLException: No suitable driver

I’m using eclipse, trying to connect to a sql server db. I have the jars in my build path. I get the error: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:325) at java.sql.DriverManager.getConnection(DriverManager.java:353) Here is my code: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class connect { public void dbConnect(String db_connect_string, String db_userid, String db_password) […]

Hql query optimization – return indexed id or the whole object

I have a databas table with cca. 327 000 entries. (SQL Server 2005, Hibernate 3) I have to generate a report that queries this table for 300 times. The Hql query looks like this: select hist from HistoryTable hist where year(hist.date) = :year and hist.user.userId = :userId and hist.entryType = :created I need to wait […]

Can I amend the executed SQL before execution using an AspectJ pointcut

I’m trying to add a specific piece of SQL to all SQL executed in a system using AspectJ. I’ve not used AspectJ before but I believe what I need to do is create a pointcut on call(PreparedStatement Connection.prepareStatement(String)) and provide the advice before(Connection con, String sql): call(PreparedStatement Connection.prepareStatement(String)) && target(con) && args(sql) { sql = […]

JDBC | SQL Server connection error

I’m trying to generate some reports to my system using Jasper reports. I’m suing basic JDBC connection method to establish a connection to my SQL Server 2000. Here is my code snippet: public static Connection getConnection()throws ClassNotFoundException, SQLException { Class.forName(driver); Connection conn = DriverManager.getConnection(connectString, user, password); return conn; } But I’m getting a SQL incorrect […]

method takes too long

I wrote a method that gathers data from an Oracle server, formats and encrypts the data then inserts it into a MS SQL server. The method moves about 60000 records and takes a bit long and is a little sloppy. Can anyone see places to clean it up and make it faster? 2 of the […]

criteria query ORDER BY yields error. Is this an SQL-SERVER limitation? How could I order by correctly on a complicated criteria query?

I have the following criteria query: String cat = “H”; Criteria criteria = currentSession().createCriteria(this.getPersistentClass()). add(Restrictions.ne(“category”, cat)). createAlias(“employees”, “emp”). createAlias(“emp.company”, “company”); Disjunction disjunction = Restrictions.disjunction(); for(Region r: regions){ disjunction.add(Restrictions.eq(“company.region”, r)); } criteria.add(disjunction); if(status != null) { criteria.add(Restrictions.eq(“status”, status)); } if (period != null) { criteria.add(Restrictions.eq(“period”, period)); } criteria.setProjection(Projections.groupProperty(“id”)) //this line was added to try to “fix” […]

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