Posts

Showing posts from January, 2009

How to pass a collection of data to SQL Server

Hi all. If you are faced with a situation where you wish to send an array of strings(say) to the Server, then you have stumbled to the correct page :-) To start off with, SQL server up to 2005 does not support Arrays. So, it becomes a bit difficult for Java,C#,C++ programmers who are very fond of arrays to get their job done. Fortunately there is a detour which enables us to get the job done. Instead of sending the list as an array, we can append a delimiter(here I used the comma) and send the complete string to the server side. At the server side, it splits the separate strings by the delimiter and inserts them into a table(her I used it as a single column table of the form tmpTable(_name varchar(50))) You can use the values inserted into this table and use the results similar to having an array. NOTE: It does not support the sophisticated array functions you are used to, but it will let you get the job done. /* PROCEDURE NAME : readCSV AUTHOR : Ruchira Randana PROCEDURE DESC

Connect SQL Server Express 2005 with NetBeans IDE

Image
Hi, Most of you Java Folks may have encountered situations where you wish to code using Java but need to connect to a Microsoft SQL Server Database. To an experienced person, this may seem trivial, but for newbies, this can be a troublesome task. Through this post, I would briefly describe how to connect to Microsoft SQL Server 2005 Express Edition using NetBeans 6.0.1 IDE. STEP 1: Download the relevant JDBC driver from the microsoft site. (A search on the internet will more than suffice) STEP 2: Add the driver to NetBeans IDE. This can be done as follows. On the services tab, under Databases under Drivers, you can add a new driver as follows On the Window, click Add and select the necessary Jar file of the driver. Then click Find. It will search the class name and display it as follows Once the driver is installed, you can right click on it and click 'connect using' Then you will get the following screen Fill in your database name and host address. The port is usually 1433. Yo