Tag: java

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”); […]

JBoss AS 7 Datasource to SQL Server using Windows Integrated authentication

The title is pretty explanatory. I need to configure a datasource in JBoss AS 7 that will connect to a SQL Server 2008 R2 database using windows integrated. I have searched a lot but all the examples just use SQL authentication.

Run *.sql files in sequence from an XML file using “ant” command (building i2b2 ontology database on SQL Server 2008 Express)?

Below are commands in an i2b2 database setup tutorial to create a bunch of tables and load the data for a particular database. I’ve only run *.sql commands manually (in a new query window) in SQL Server Management Studio (SSMS) before. Is this something that must be run from Java, or can I do this […]

connecting to the database engine in Microsoft SQL Server 2005

I had to connect my netbeans application to Microsoft SQL Server 2005 so that I am able to read the data back to application (after I store it !) . But I haven’t been able to create a table yet since I am able to connect to the database engine as it says. How do […]

Executing a sql server query containing clause “ where col like N'myStr%' ” from java using spring

my query works using sql server management studio. However I can not get the query to work with named parameters and springsJDBCTemplate. So actual sql required that works fine : select colA from table1 where colb like N’lem%’ and a snippet of what I have tried : String paramA = “N’lem%'”; select colA from table1 […]

Error while converting nvarchar to datetime

I would like to execute my MSSQL stored procedure from my java program by giving as parameters two dates to have aselection between this two dates. So in java code I proceeded like this: “EXEC [dbo].[MyProcedure] ” + “‘”+ dateFrom+”‘” ,”‘”+dateTo”‘” I have declared my parameters in sql server procedure like this way : @collected_date1 […]

How to read/export XML file which is output from SQL server in JAVA

I have a Query, which I execute in SQL server 2005/2008, gives me output in XML format. Here is the sample query to generate xml output : SELECT (SELECT ‘White’ AS Color1, ‘Blue’ AS Color2, ‘Black’ AS Color3, ‘Light’ AS ‘Color4/@Special’, ‘Green’ AS Color4, ‘Red’ AS Color5 FOR XML PATH(‘Colors’),TYPE), (SELECT ‘Apple’ AS Fruits1, ‘Pineapple’ […]

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