Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.databases > #306
| From | "Starbuck" <starbuck@THRWHITE.remove-dii-this> |
|---|---|
| Subject | java and ms-server |
| Message-ID | <eLYMk.23884$7q6.21735@newsfe10.ams2> (permalink) |
| Newsgroups | comp.lang.java.databases |
| Date | 2011-04-27 15:22 +0000 |
| Organization | TDS.net |
To: comp.lang.java.databases
Hi Folks
New to the group to sorry if this has been asked before.
I am learniing Java at Uni and so far I have connected to a MS Server
and I have read data ok. Now I want to connect to the stored procedures
already in place.
Below is a procedure in question -
CREATE PROCEDURE record_count
(
@cnt int OUTPUT
)
AS
BEGIN
/* Procedure body */
SELECT @cnt = count(8)
From curry
END
Nice and easy returns number of records in table.
Here is my working c# code
public int recCount()
{
try
{
openCon();
//not sure from here peeps
SqlCommand cmd = new SqlCommand("record_count", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter countParameter = new SqlParameter("@cnt", 0);
countParameter.Direction = ParameterDirection.Output;
cmd.Parameters.Add(countParameter);
cmd.ExecuteNonQuery();
int rc =
Int32.Parse(cmd.Parameters["@cnt"].Value.ToString());
if (con.State == ConnectionState.Open) con.Close();
return rc;
}
catch (Exception ex)
{
string exx = ex.Message ;
return 0;
}
}
Can anyone point me in the correct direction for the Java method please.
Many thankings in advance.
KC
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.databases | Previous | Next — Next in thread | Find similar
java and ms-server "Starbuck" <starbuck@THRWHITE.remove-dii-this> - 2011-04-27 15:22 +0000
Re: java and ms-server "=?ISO-8859-1?Q?Arne_Vajh=" <=?iso-8859-1?q?arne_vajh=@THRWHITE.remove-dii-this> - 2011-04-27 15:22 +0000
Re: java and ms-server "Starbuck" <starbuck@THRWHITE.remove-dii-this> - 2011-04-27 15:22 +0000
Re: java and ms-server "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
Re: java and ms-server "David Harper" <david.harper@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
Re: java and ms-server "Starbuck" <starbuck@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
Re: java and ms-server "John W Kennedy" <john.w.kennedy@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
Re: java and ms-server "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
Re: java and ms-server "Martin Gregorie" <martin.gregorie@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000
csiph-web