SQLserver 2 « SQLserver « Java Database Q&A





1. Is it OK to close JDBC connection from another thread on timeout?    stackoverflow.com

Because none of the JDBC operations have a concept of timeout, is it advisable to try to close JDBC connection of the overdue operation from the other thread if timeout is ...

2. Suppressing "X rows affected" in SQL Server using sqlcmd and Java    stackoverflow.com

In my Java program, I am trying to execute a bunch of SQL scripts using sqlcmd via getRuntime.exec(). Earlier, I had been using osql this way -

osql -n -S SERVER -U sa ...

3. "Main loop" in a Java application on JBoss server    stackoverflow.com

I am creating a JBoss server to deploy a java application which will be a REST-like servlet taking data from requests and placing them into a SQL database. My main question: Is ...

4. MS SQL JDBC - SQLServerCallableStatement - execute() returns false    stackoverflow.com

I have written code which should call MSSQL 2005 procedure from my servlet. The problem is the procedure is to SELECT data from table so I want to get ResultSet but ...

5. JDBC connection to Microsoft SQL Server doesn't reconnect    stackoverflow.com

I have a database that is connected through an unreliable network connection to an application server, so occasionally the connections break down. Each time this happens, all database connections in the ...

6. how to move a particular row of ResultSet to the End of it in MSSQL?    stackoverflow.com

My question is : I want to move a particular row to the end of a MSSQL resultset in java. How can this be done ? I found a reference in MySQL ...

7. Reading BCP files in Java    stackoverflow.com

Is there any Java library (or example code) for reading files produced by the command-line Microsoft Bulk Copy (BCP) utility, used for importing/exporting SQL Server data? Some similar work is ...

8. Specify SQL Server instanceName in WebSphere 7    stackoverflow.com

I have this SQL Server Database with two instances and I'm trying to create a connection pool in WAS7 but I don't know how to specify the instance name. I've tried ...

9. JDBC SQLException for SQL Server    stackoverflow.com

I have this piece of code which works well on DB2 and Oracle, but fails on MSSQL(both 2005 and 2008).

c = SessionMgr.getInstance().getTOPLinkManager().getDataSource().getConnection();
String sql = "";
sql = "{CALL " + TOPLinkManager.getSchemaPrefix() + ...





10. Binding Sql Server and XML    stackoverflow.com

I have a Sql Server database (version 2008 running databases in 2000 mode) and I want to generate some XML files using data from this db. I have XML schema for ...

11. Fetch a variable set within a transaction    stackoverflow.com

I have a piece of java code that connects to a SQL Server that does something like the following: First a bunch of batch through stmt.addBatch

declare @crt_dt as datetime
set @crt_dt = (select ...

12. sqljdbc4 hangs after update to Apple Java for Mac OS X 10.6 update 6    stackoverflow.com

The lastest Apple Java for Mac OS X 10.6 update 6 hangs my mssql jdbc driver (sqljdbc4.jar), has anybody else run into this problem? Any fixes? Anybody know a way to ...

13. Display SQL Server table values using jdbc    stackoverflow.com

Below is my code to display SQL Server values using jdbc. I have a problem. it says it is connected, but cannot display the values from the table specified. it says, ...

14. Reading output file of SQLCMD using Java    stackoverflow.com

I am executing a bunch of SQL scripts and trying to read the output log file, looking for errors, after each file is executed. Here's how I execute the script.

String strCommand = ...

15. mssql port auto detect    bytes.com

Hi, In Windows programming, there is a built-in function to get MSSql database server names and connect to it without needing to know the port numbers. Is it possible to do ...

16. sql server    bytes.com

Hi all, I have a problem that need to solve: I have a table that is called empVisit. There was a error when inserting: Violation of PRIMARY KEY constraint 'PK_EmpVisit'. Cannot ...





19. Netbeans 6.7.1 MS SQL Server JDBC 2.0    forums.netbeans.org

Hello, I've been recently trying to create a database connection in Netbeans that utilizes Microsoft's JDBC 2.0 driver for SQL Server. While I'm confident it would work in code, using the ...

20. Create entity from database for SQL server connection    forums.netbeans.org

Hello everybody. I'm implementing a web service, and I have to use data from a SQL server database. When I start to configure a entity class from database, it doesn't retrieve ...

21. jdbc:sqlserver connection shows view but Desktop Application does not    forums.netbeans.org

Posted: Tue May 25, 2010 8:22 pm Post subject: jdbc:sqlserver connection shows view but Desktop Application does not I am fairly of new to NetBeans -- most of ...

22. Sql Server 2008 R2 Data Source problem in NetBeans 6.9    forums.netbeans.org

I am trying to create Entity Classes from Database using NetBeans 6.9. Setup the database and connected to the SQL Server 2008 R2 database in the Services tab using sqljdbc4.jar jdbc ...

23. Embedding JRE and MSSQL Express with database in Netbeans RCP installer (Netbeans 6.9)    forums.netbeans.org

Hi everyone, I want to embed JRE and my MSSQL database in my RCP Application's installer (i.e. in Netbeans 6.9). The installer should ideally install the MSSQL Express edition with my ...

24. Telephone book JAVA + JDBC + MSSQL    forums.netbeans.org

25. connection to ms sql server    forums.netbeans.org

hello everyone! i have a db in ms sql server 2008, i connected in server tab of my netbeans ide 6.9.1 i installed the driver and successfully connected but when i try to connect a code to the db i cannot. i use this url "jdbc:sqlserver//localhost:1433;" + "databaseName=DB_name; user=sa; password=******"; whene i run the code just i get this: run: java.lang.NullPointerException ...

26. Importing Jobs into SQL Server tables    forums.terracotta.org

27. MSSQL and selectWithLockSQL    forums.terracotta.org

Even with latest Quartz (2.0.0), default selectWithLockSQL doesn't work for MSSQL (2008 R2). I'd expect it to work when MSSQLDelegate is configured, but it doesn't work, even then same error occurs (see [1] for error stacktrace). Problem disappears when besides configuring driverDelegateClass I configure org.quartz.jobStore.selectWithLockSQL to be "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?" Question is, can this be ...

28. Moving Quartz DB from MSSQL to Postgres    forums.terracotta.org

Hi All, Can anyone offer advice about moving the Quartz database between dbservers. I have Quartz storing scheduled jobs on a MSSQL database. I need to switch to over to use a PostgreSQL database instead. I am having trouble migrating the data. I believe that the problem is the job_data column in the job_details table. This column contains binary data. Its ...

29. Failed to obtain DB connection for SQL server    forums.terracotta.org

Hi, I am trying to write sample example for JDBCJobStore which connects to my sql server database which has Quartz tables. I am getting following error Jun 17, 2011 10:49:21 AM org.apache.catalina.core.ApplicationContext log INFO: QuartzInitializer: Quartz Scheduler failed to initialize: org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'myDS': java.sql.SQLException: Connections ...

30. MS SQL Server Deadlock - LockException: Failure obtaining db row lock    forums.terracotta.org

Platform: JBoss 4.2.3 Quartz version: 2.0.2 Database: MS SQL Server 2005 Jdbc jar: sqljdbc.jar We recently upgraded from Quartz 1.7.3 to 2.0.2. It went well, and we haven't had any problems up until last night. Last night we experienced a few deadlocks while our code attempted to schedule some jobs. We tested this thoroughly in QA before moving it to Production, ...

31. Benchmarking MS SQL Server: suggestions?    jmeter.512774.n5.nabble.com

Hi List! I've been working this week on a quite complex Test Plan to load test our DB add, based around MS SQL Server (hence my various questions bugging this list). Working earlier this evening, our senior architect identified that during the JMeter load test our SQL server was carrying out a lot of stored procedure recompiles. He wondered if this ...

32. Implementing SQL Server Reporting Services with a Java EE Application    coderanch.com

Hi All, I need to find some tutorial on "Implementing SQL Server Reporting Services with a Java EE Application" for my j2EE application. Until now i have searched a lot of sites but have not any thing related to this topic. I am using apache axis along with SQL Server Report Manager for creating the sql server reports. I have done ...

33. Modify PDF content fetched as a blob from SQL server    coderanch.com

I am fetching a PDF file stored as a BLOB in SQL Server Database. Before streaming the PDF in the browser, I want to make a few changes to some of the URL (links) existing in the PDF. I am using the following code: pdfBlob is a Blob object. It contains the PDF image fetched from database. try { byte [] ...

34. JDBC to SQL Server    coderanch.com

35. Stored proceduresand sql-server    coderanch.com

36. getting values by calling stored proc. in sql server    coderanch.com

Friends, I just wanted to know that how would u get the value of a variable (which is an output parameter in sql server) by calling it in java. example create procedure proc1 (@a varchar(10), @id varchjar(3) as begin select @id=@a+' returned value' end above is a procedure made in MS sql server. now what i want is by calling this ...

37. Connection pooling with SQL Server    coderanch.com

38. JDBC with MSsql server without DSN    coderanch.com

39. J2EE + MS SQL SERVER    coderanch.com

thanks for ur reply Raj. i have accessed the database successfully usnig the same piece of code on Tomcat server but getting problems on J2EE, might be i have to make changes in some J2EE files but don't know wht and where ?? i tried to change server.xml but of no use....... i'm still clueless abt the solution, if u or ...

40. Using SQL Server @@IDENTITY    coderanch.com

41. JDBC in MS Sql server    coderanch.com

Hi, Let me say my problem I am developing a web application using jrun app server on IIS. Database is MSSql Server ver 7.0. I use Weblogic type 4 driver for data connectivity. Initially the database was installed without any service pack. I was able to execute stored procedures without any problem. But after installing MS Sql server v 7.0 with ...

43. Replication of data in SQL Server    coderanch.com

Hi, Reqt. is to replicate data in two DB servers(using Publication & Subscription in SQL Server2000) as data is synchronized , initially I fetch data from First DB server, if its down I go for Secong DB server and fetch the data and vice versa as this procedure continues throughout my application and so need to ping everytime I open a ...

44. Solution of rs.previous() using sql server    coderanch.com

Hai Friends, I have got a good solution for rs.previous() method using sql server 2000 you can make use of this program in your application this program is working perfectly if you have any doubts and clarifications pl mail me this program uses jdk 1.3. sql server 2000 and jdbc odbc driver. Bye ************************************** import java.awt.*; import java.awt.event.*; import java.sql.*; public ...

46. Storing/retrieving files in/from sql server thru java    coderanch.com

Hi Priya I have just checked in SQL Online books and there are some data types like Text and Image. Text can store data contained in .txt files and logos and images can be stored in image data type. Hope this gives u some direction. will let u know once i get more details. Regards Venu

47. Poolman with MS SQL Server    coderanch.com

We're trying to use Poolman, JDBC 2.0, MS SQL Server using the JDBC/ODBC bridge. I have set up my poolman.xml file and have a little sample application. (code posted below). When I run my query, I get the right number of records. However, when I do a resultset.getstring("name"), I get null. Any ideas/suggestions/hints? Thanks... // Code Studio PoolMan Library import com.codestudio.util.*; ...

48. Tables Count in Sql Server    coderanch.com

there is a sql statement which unfortunately is on my pc at home so i don't have it here, but there is a dictionary table in the sql server with the names of all tables, columns, fields, indices etc in, and it's easy to query for whatever info you need. i'll try to remember to post it tonight.

49. JDBC, orion server and SQL Server    coderanch.com

Hi everyone, I am trying to connect to a SQL Server database using servlet, which is hosted by Orion Application Server (www.orionserver.com), Linux server. And I hope someone will be able to help me ! After some debugging, I think that this is the part with problem: try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://ServerName ort", "username", "password"); } catch (Exception e) ...

50. Calling MS SQL DTS Package From Java    coderanch.com

51. Output Parameters - anything different for SQL Server 7?    coderanch.com

Completely green here - I've seen other threads that address similar questions, but haven't yet seen an answer. . . I'm executing a stored procedure in SQL Server 7 using the CallableStatement. The first parameter to my stored procedure is an OUTPUT parameter, so specc'ed in the CREATE PROCEDURE statement. I register the parameter as an output parameter for the CallableStatement, ...

52. Perf Problems w/ SQL Server 7.0    coderanch.com

I am getting terrible performance using Jrun w/ SQL Server 7.0. Im using the standard Merant drivers supplied w/ Jrun. We thought that the problem could be with connection pooling, so weve tried many options of how to allocate connections but none seem to be too great. We have a lot of tables in the DB (>150). Has anyone had similar ...

53. SQL server 7.0 and Java    coderanch.com

There's a concept of an extended stored procedure, which is essentially a DLL that you write that SQL Server can execute. You would then write your trigger to execute the extended stored procedure if your condition was met, and your extended stored procedure would then trigger your Java code. Unfortunately, I have no experience doing this sort of thing, so can't ...

54. proper url for mssql 7 server? (newbie question)    coderanch.com

Hi, I've found some good examples of connecting to a database using a jdbc-odbc bridge, and I got it to work on a little access database. Now I need to connect to my real database, which is ms sql server 7. I see where to specify the dns, and I know I specify the table in the query, but where do ...

55. MS SQL Server 7    coderanch.com

56. SQL Server Floating Point    coderanch.com

57. Sniffing out apostrophe's in SQL Server    coderanch.com

Hi Ranchers, I came up with the following code that sniffs out any apostrophe's occuring in data that is to be inserted/updated to an SQL Server table: public String sniffOutApostrophe(String passedValue) { StringBuffer passedValueSB = new StringBuffer(passedValue); for (int i = 0; i < passedValueSB.length(); i++) { if (passedValueSB.substring(i, (i+1)).toString().equals("'")) { passedValueSB.replace(i, (i+1), "''"); i++; // Don't leave this out or ...

58. SQL Server replacing characters    coderanch.com

Whenever I attempt to retrieve my data from an SQL Server database or a MSAccess database characters like apostrophes ' or double quotes " are changed into other characters such as / and ?. I've checked the database and the data is correct. Has anyone else experienced this problem and does anyone know a solution?

59. JDBC / sql server connection    coderanch.com

60. class path for ms sqlserver database    coderanch.com

You'll probably find this is a problem with the location of your JAR and not specfically JDBC-related. Depending on the App-server you are using, you need to put the JAR somewhere it can be seen by the web-app. Without going into the specifics (you can get the whole story if you do a search in this or the Servlet forums) web ...

61. visual J++ and retreiving rows from sql server    coderanch.com

Originally posted by Sanjeev Shahi: need urgent help!!! I am trying to retreive data from SQL server in visaual J++. I've created new database project and in the explorer I can see the database and tables. The ques. is now what I've to do to display the records in the table? pls reply asap thanks ss Try to be more specific ...

62. BLOB Creation in Java (MS SQL Server or generic)    coderanch.com

I'm working with BLOBs using Microsoft SQL Server 2000 JDBC drivers and attempting to insert and query a BLOB that represents a file. I can get a BLOB (assuming it works once I have one loaded -- it currently shows as null) but I need to create one from a file (not the database). I searched the JavaRanch forum history and ...

63. Retrieving LONGVARCAR data type from SQL Server    coderanch.com

Hello, I've got a recordset from a Query in a SQL Server db. What I'm trying to do is just print out the columns. All is fine when the data types are CHAR or INT but things go wrong when it is LONGVARCHAR (text field in MS SQL). When I try to print out the result I just get the text ...

68. jdbc with SQL Server    coderanch.com

This is pretty well documented, so I won't go into details. Basically you have a couple of choices, depending on the platform that your application is hosted on. If you are running on a Windows platform: 1) Create a system DSN pointed at the SQL Server instance and target database. 2) Use the jdbcdbc bridge that comes with your J2SDK. Or, ...

69. Basic SQL Server JDBC problem    coderanch.com

70. JDBC SQL Server    coderanch.com

Hi!, I am trying to connect to a remote SQL Server database from a java swing application. I have 2 constraints : 1. DSN less connection is to be there. 2. I need NT authentication. I came to know that for this type of connection TYpe 3 drivers are suitable. Can anyone suggest some free TYpe 3 drivers. And how to ...

71. No such column in SQL server    coderanch.com

When using my code(BMP), JBoss + MySQL on my development machine it all works well. Transferring the same code to another machine JBoss + MS SQL Server 2000 throw a JDBC exception. my BMP code uses the following SQL statement select Tblcriteria.DOCcriteria, TblCapability.CoreCapability, TblClass.Classification, TblEntry.* from Tblcriteria, TblCapability, TblEntry, TblClass WHERE TblEntry.Classification = TblClass.ID AND TblEntry.DOCCriteria = Tblcriteria.DOCcriteriaID AND TblEntry.Capability = ...

72. JDBC & SQL Server    coderanch.com

75. jdbc connection to ms sql (urgent)    coderanch.com

Madhu, Below a test that I first worked with when I wanted to get to know JDBC: import java.util.*; import java.net.*; import java.io.*; import java.sql.*; public class ODBtest { public static void main( String argv[] ) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc :-o dbc:SAMTEST"; Connection con = DriverManager.getConnection(url); if (con != null) System.out.println("Connection Successful!"); Statement stmt = con.createStatement(); ResultSet ...

76. Getting identity value with MS Sqlserver    coderanch.com

I am using the microsoft driver for sqlserver 2000. Does anyone know how to retrieve the value for an identity column after an insert. When I tried "select @@identity from tablename" after a successful insert statement it returned a value of 0 for every row in the table. Has anyone had any success using this driver from microsoft? Thanks

77. JDBC with Chinese Traditional (SQL Server)    coderanch.com

Hi all I am having problems using JDBC (JDK 1.3) when I am trying to update my database (SQL Server) with certain Chinese Charaters. I am trying to update data in a table with non-Unicode datatype (varchar) and some characters are giving problem (characters with character codes 29054, 29055, etc). The JDBC Connection with Data base was obtained using Properties props ...

78. How to set TIMEOUT in MSSQL?    coderanch.com

I execute this SQL in MSSQL and prompt me a timeout box, i wonder how i can set the MSSQL's query timeout? SQL: SELECT c.theme_title, c.grade_id, b.sub_theme_title, count(a.cd) FROM hit_rates_report_log a, sub_theme b, theme c WHERE a.type = 'SUBTHEME' AND a.cd = b.sub_theme_cd AND b.theme_cd = c.theme_cd AND (access_time >= '2003-6-15 00:00:00') AND (access_time <= '2003-7-15 23:59:59') AND b.theme_cd IN (SELECT ...

79. help needed for MS SQL Server    coderanch.com

80. MS SQL SERVER StTORED PROCEDURE    coderanch.com

82. System DSN for MS SQL Server    coderanch.com

83. Setting classpath for sql server    coderanch.com

84. My SqlServer    coderanch.com

I have created a new database on mysql database. However I can not get my code to connect to it. I keep getting the problem that my tables have not got primary keys. However, the same code and the same driver works on the northwind databse. I am going mad with this problem. Any suggestions would be greatly apprechiated. Thank you ...

85. Connection with SQL Server    coderanch.com

86. SQLServer thindriver for Tomcat5.0    coderanch.com

87. JDBC to MS SQL Server    coderanch.com

88. connet to sql server and run query    coderanch.com

89. Searching technique used by SQL server    coderanch.com

SQL doesn't specify anything about how the database works; it only specifies how to talk to it. Every database will be implemented differently, and closed-source database vendors of course don't share their code or algorithms, so for many databases, the precise answer is not known nor knowable. But in general, for a WHERE clause that mentions a single column of a ...

90. SQL-server    coderanch.com

91. MS SQL Server and alue can not be converted to requested type    coderanch.com

I use Xdoclet, so everything is same. OK, you use XDcolet to generate the DB schema, right? Back to my point. Lets assume I have a table Table1 which has a column date1 of type "datetime" (or similar). If I execute a piece of code like this: stmt = connection.prepareStatement( "UPDATE Table1 " + "SET date1=?"); stmt.setString(1, "1/1/1990"); stmt.executeUpdate(); It might ...

92. Clustered columns confusion in MS SQL    coderanch.com

hi all, I understand this is more of an MS SQL issue than a JDBC issue,but I havent been able to find the reason as to why this happens. the trouble is,I am firing the following query, "update LOG_HDR set MSG=?, COMMENT=?, SIZE=? , CONTENTS=? ,AUDIT=? where ID=? " In this query, ID is a primary key clustered column. All the ...

93. Ant, JDBC, MS SQL Server    coderanch.com

Unnsse, Bear, possibly others, Please accept my apologies for any rudeness. I am afraid I have tried to leap further than my knowledge of english allows for in using the term 'good riddance'. I have in the meantime found out it is not exactly related to riding, as I thought. I must say, though, that I have not really found why ...

94. SQL SERVER    coderanch.com

Hi guys, DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver()); Connection connection = DriverManager.getConnection( "jdbc:microsoft:sqlserver://:1433",<"UID>",""); Im using driver type-4 .Im able to connect to a database in my SQL SERVER but I do not know how can this code locate the driver since I did not mention the database name nor the dsn.Can anyone please tell me how they locate the driver bye nitin

95. SQL Server & jwsdp1.3    coderanch.com

Last year I tried the examples with the example database in jwsdp manual (pointbase) and now I want to develope some examples with the database SQL Server. How do I configure the odbc and all the parameters in the Apache Admin tool? I am a newcomer about sql server, so any help would be great, thanks in advance, Gobellot

96. HELP please with SQL Server    coderanch.com

Well I changed the code because I am trying to test the connection but orinally I will connect through JSp. this is the code: import java.sql.*; public class TestarConnect{ Connection conn; public static void main(String [] args) throws ClassNotFoundException { String uname = "Username"; String pwd = "password"; String url = "jdbc:microsoft:sqlserver://server:1433"; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); DriverManager.getConnection(url,uname,pwd); System.out.println("Connection Successfull"); } catch(SQLException e){ ...

97. How to establish JDBC Connection to SQL Server    coderanch.com

You need to move the jar files (msbase.jar, mssqlserver.jar, msutil.jar) from the lib directory of the default install location of the drivers, i.e. C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib - into your class path, somewhere along the way. Your class compiles fine because you don't actually reference the sql driver until run time.

98. How do i know , on which port MS Sql Server is running?    coderanch.com

If you want to know what port a process is using on windows use netstat -ao. You should be able to find the PID that way, then use something like Process Explorer to work out what the process with that PID is called. Another useful trick when using SQL Server is to create a .udl file (just create a text file ...

99. Using Clobs in SQLServer- Please help!    coderanch.com

/* CAN ANYONE PLEASE HELP ME OUT WITH THIS PROGRAM. PLEASE READ THE COMPLETE PROGRAM AND GIVE ME YOUR SUGESTIONS. THE DATABASE BEING USED IS MS SQLSERVER This program retreives the text file stored in the database installed by the previous program SaveToClob() (Not displayed in this snippet). The table created in the database consists of the following columns := static ...

100. sqlServer connection    coderanch.com