Here's a weird one.
I've got a job on one server, owner 'sa'. It runs fine. I created the
same job on another server, still with owner 'sa', and it fails. When I
view the history, it fails because it's running as a different user,
one without the necessary rights. On the server that it works on, the
job is being run as the correct user, 'sa'.
In the step, under advanced, 'Run as user:' is set to '(self)', just as
it is in the server that works.
Help! I cannot see any difference between the jobs on the 2 servers,
and I can't think of any reason why it's trying to execute the job as a
user other than the owner.
Hi,
Have a look into the SQL Agent startup account. See if it have necessary
rights.
Thanks
Hari
SQL Server MVP
<ben.bawden@.btopenworld.com> wrote in message
news:1129111265.698508.242580@.g43g2000cwa.googlegr oups.com...
> Here's a weird one.
> I've got a job on one server, owner 'sa'. It runs fine. I created the
> same job on another server, still with owner 'sa', and it fails. When I
> view the history, it fails because it's running as a different user,
> one without the necessary rights. On the server that it works on, the
> job is being run as the correct user, 'sa'.
> In the step, under advanced, 'Run as user:' is set to '(self)', just as
> it is in the server that works.
> Help! I cannot see any difference between the jobs on the 2 servers,
> and I can't think of any reason why it's trying to execute the job as a
> user other than the owner.
>
|||Check *both* the job as a whole and each jobstep. Job should be owned by "sa" and job step should be
<self>. Double and triple check.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<ben.bawden@.btopenworld.com> wrote in message
news:1129111265.698508.242580@.g43g2000cwa.googlegr oups.com...
> Here's a weird one.
> I've got a job on one server, owner 'sa'. It runs fine. I created the
> same job on another server, still with owner 'sa', and it fails. When I
> view the history, it fails because it's running as a different user,
> one without the necessary rights. On the server that it works on, the
> job is being run as the correct user, 'sa'.
> In the step, under advanced, 'Run as user:' is set to '(self)', just as
> it is in the server that works.
> Help! I cannot see any difference between the jobs on the 2 servers,
> and I can't think of any reason why it's trying to execute the job as a
> user other than the owner.
>
|||Hi. The SQL Server Agent startup account is the same on both servers.
However server1 is running the job as sa, and server2 is running the
job as the SQL Server Agent startup account. Strange.
I've double, triple, quadruple checked that the job in question is set
to owner sa and the step is set to self.
Other jobs on the server are also running as the non-sa account, but
this one is the only one that's failing, because it's running through a
linked server. As a work around I've built a DTS package that runs the
task, and then scheduled that DTS package, but I'd really like to
understand why this server is running jobs under the non-sa account.
|||I'm not sure whether you are talking about TSQL or CmdExec job step. However, two things to check:
1 EM, Agent, right-click, properties, right-most tab. Check how agent log on to SQL Server.
2 Security mode for each SQL Server (Windows only or mixed).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<ben.bawden@.btopenworld.com> wrote in message
news:1129115237.379149.269800@.g43g2000cwa.googlegr oups.com...
> Hi. The SQL Server Agent startup account is the same on both servers.
> However server1 is running the job as sa, and server2 is running the
> job as the SQL Server Agent startup account. Strange.
> I've double, triple, quadruple checked that the job in question is set
> to owner sa and the step is set to self.
> Other jobs on the server are also running as the non-sa account, but
> this one is the only one that's failing, because it's running through a
> linked server. As a work around I've built a DTS package that runs the
> task, and then scheduled that DTS package, but I'd really like to
> understand why this server is running jobs under the non-sa account.
>
sql
Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts
Wednesday, March 21, 2012
Job History is missing
I've come into a new SQL server 200o environment and for some reason, none of
the jobs keeps a history past one day. The current production DBA says he has
no idea what's causing it. Does anyone have any experience with this issue?
Thanks in advance.
See if the size of the job history has been limited. This can be found in
Enterprise Manager by selecting your server, going to Management, then right
click on SQL Server Agent and select properties. The Job System tab has
options for limiting the size of the job history log.
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:881853B8-2F60-4017-8F01-44FBF863BFAF@.microsoft.com...
> I've come into a new SQL server 200o environment and for some reason, none
> of
> the jobs keeps a history past one day. The current production DBA says he
> has
> no idea what's causing it. Does anyone have any experience with this
> issue?
> Thanks in advance.
|||Thanks Ben, that was fast. I think that will do it. Thanks again.
Ed
"Ben Lucas" wrote:
> See if the size of the job history has been limited. This can be found in
> Enterprise Manager by selecting your server, going to Management, then right
> click on SQL Server Agent and select properties. The Job System tab has
> options for limiting the size of the job history log.
> --
> Ben Lucas
> Lead Developer
> Solien Technology, Inc.
> www.solien.com
> "Ed" <Ed@.discussions.microsoft.com> wrote in message
> news:881853B8-2F60-4017-8F01-44FBF863BFAF@.microsoft.com...
>
>
the jobs keeps a history past one day. The current production DBA says he has
no idea what's causing it. Does anyone have any experience with this issue?
Thanks in advance.
See if the size of the job history has been limited. This can be found in
Enterprise Manager by selecting your server, going to Management, then right
click on SQL Server Agent and select properties. The Job System tab has
options for limiting the size of the job history log.
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:881853B8-2F60-4017-8F01-44FBF863BFAF@.microsoft.com...
> I've come into a new SQL server 200o environment and for some reason, none
> of
> the jobs keeps a history past one day. The current production DBA says he
> has
> no idea what's causing it. Does anyone have any experience with this
> issue?
> Thanks in advance.
|||Thanks Ben, that was fast. I think that will do it. Thanks again.
Ed
"Ben Lucas" wrote:
> See if the size of the job history has been limited. This can be found in
> Enterprise Manager by selecting your server, going to Management, then right
> click on SQL Server Agent and select properties. The Job System tab has
> options for limiting the size of the job history log.
> --
> Ben Lucas
> Lead Developer
> Solien Technology, Inc.
> www.solien.com
> "Ed" <Ed@.discussions.microsoft.com> wrote in message
> news:881853B8-2F60-4017-8F01-44FBF863BFAF@.microsoft.com...
>
>
Monday, March 19, 2012
Job Hangs...
I've seen several posts concerning Jobs Hanging with "Executing Step
1..." whatever .. I have a job that will sometimes do that as well.
It's a small data mining type thing that runs a couple of times a day
- and missing a run is not a problem. BUT - when it hangs, it won't
run again until someone stops it.
Therefore - can someone tell me how to issue a command to stop/cancel
a job? I can just schedule that job 10 minutes before the one that
hangs... then just hope the "Stop the Hanging Job" job doesn't
hang...
You could try running sp_stop_job. If this isn't relevant for your type of
process, you could use sp_who2 to see what the process is doing and use KILL
on the relevant SPID.
HTH,
Paul Ibison
|||Kill <SPID> is your safest bet to stop it.
On Apr 23, 9:12 am, Ray <ray_p...@.bellsouth.net> wrote:
> I've seen several posts concerning Jobs Hanging with "Executing Step
> 1..." whatever .. I have a job that will sometimes do that as well.
> It's a small data mining type thing that runs a couple of times a day
> - and missing a run is not a problem. BUT - when it hangs, it won't
> run again until someone stops it.
> Therefore - can someone tell me how to issue a command to stop/cancel
> a job? I can just schedule that job 10 minutes before the one that
> hangs... then just hope the "Stop the Hanging Job" job doesn't
> hang...
|||Thank you very much...!!!
On 23 Apr 2007 10:09:10 -0700, tmorris <TheRealPawn@.gmail.com> wrote:
>Kill <SPID> is your safest bet to stop it.
>On Apr 23, 9:12 am, Ray <ray_p...@.bellsouth.net> wrote:
>
1..." whatever .. I have a job that will sometimes do that as well.
It's a small data mining type thing that runs a couple of times a day
- and missing a run is not a problem. BUT - when it hangs, it won't
run again until someone stops it.
Therefore - can someone tell me how to issue a command to stop/cancel
a job? I can just schedule that job 10 minutes before the one that
hangs... then just hope the "Stop the Hanging Job" job doesn't
hang...
You could try running sp_stop_job. If this isn't relevant for your type of
process, you could use sp_who2 to see what the process is doing and use KILL
on the relevant SPID.
HTH,
Paul Ibison
|||Kill <SPID> is your safest bet to stop it.
On Apr 23, 9:12 am, Ray <ray_p...@.bellsouth.net> wrote:
> I've seen several posts concerning Jobs Hanging with "Executing Step
> 1..." whatever .. I have a job that will sometimes do that as well.
> It's a small data mining type thing that runs a couple of times a day
> - and missing a run is not a problem. BUT - when it hangs, it won't
> run again until someone stops it.
> Therefore - can someone tell me how to issue a command to stop/cancel
> a job? I can just schedule that job 10 minutes before the one that
> hangs... then just hope the "Stop the Hanging Job" job doesn't
> hang...
|||Thank you very much...!!!
On 23 Apr 2007 10:09:10 -0700, tmorris <TheRealPawn@.gmail.com> wrote:
>Kill <SPID> is your safest bet to stop it.
>On Apr 23, 9:12 am, Ray <ray_p...@.bellsouth.net> wrote:
>
JOB Failure!
Hi,
I've a question related to JOB failure in the DTS package.
The following is the error from the LOG file.Could some one help me in this
regard,as how i can find the easy way out.
LOG FILE ERROR:
Execution Started: 2/24/2005 11:34:06 PM
Execution Completed: 2/25/2005 12:17:56 AM
Total Execution Time: 2629.937 seconds
Package Steps execution information:
Step 'DTSStep_DTSActiveScriptTask_1' failed
Step Error Source: Microsoft Data Transformation Services (DTS) Package
Step Error Description:Error Code: 0
Error Source= Microsoft XML Extensions to SQL Server
Error Description: [DBNETLIB][ConnectionRead (recv()).]General network
error. Check your network documentation.
Thanks,
Shyam
Shyam,
This usually means that there was an actual network problem. A switch or
router may have out of service, a cable disconnected, etc.
RLF
"Shyam" <Shyam@.discussions.microsoft.com> wrote in message
news:25D54BB1-7605-4654-ADBE-7C08CF3901B8@.microsoft.com...
> Hi,
> I've a question related to JOB failure in the DTS package.
> The following is the error from the LOG file.Could some one help me in
> this
> regard,as how i can find the easy way out.
> LOG FILE ERROR:
> --
> Execution Started: 2/24/2005 11:34:06 PM
> Execution Completed: 2/25/2005 12:17:56 AM
> Total Execution Time: 2629.937 seconds
> Package Steps execution information:
> Step 'DTSStep_DTSActiveScriptTask_1' failed
> Step Error Source: Microsoft Data Transformation Services (DTS) Package
> Step Error Description:Error Code: 0
> Error Source= Microsoft XML Extensions to SQL Server
> Error Description: [DBNETLIB][ConnectionRead (recv()).]General network
> error. Check your network documentation.
> Thanks,
> Shyam
>
I've a question related to JOB failure in the DTS package.
The following is the error from the LOG file.Could some one help me in this
regard,as how i can find the easy way out.
LOG FILE ERROR:
Execution Started: 2/24/2005 11:34:06 PM
Execution Completed: 2/25/2005 12:17:56 AM
Total Execution Time: 2629.937 seconds
Package Steps execution information:
Step 'DTSStep_DTSActiveScriptTask_1' failed
Step Error Source: Microsoft Data Transformation Services (DTS) Package
Step Error Description:Error Code: 0
Error Source= Microsoft XML Extensions to SQL Server
Error Description: [DBNETLIB][ConnectionRead (recv()).]General network
error. Check your network documentation.
Thanks,
Shyam
Shyam,
This usually means that there was an actual network problem. A switch or
router may have out of service, a cable disconnected, etc.
RLF
"Shyam" <Shyam@.discussions.microsoft.com> wrote in message
news:25D54BB1-7605-4654-ADBE-7C08CF3901B8@.microsoft.com...
> Hi,
> I've a question related to JOB failure in the DTS package.
> The following is the error from the LOG file.Could some one help me in
> this
> regard,as how i can find the easy way out.
> LOG FILE ERROR:
> --
> Execution Started: 2/24/2005 11:34:06 PM
> Execution Completed: 2/25/2005 12:17:56 AM
> Total Execution Time: 2629.937 seconds
> Package Steps execution information:
> Step 'DTSStep_DTSActiveScriptTask_1' failed
> Step Error Source: Microsoft Data Transformation Services (DTS) Package
> Step Error Description:Error Code: 0
> Error Source= Microsoft XML Extensions to SQL Server
> Error Description: [DBNETLIB][ConnectionRead (recv()).]General network
> error. Check your network documentation.
> Thanks,
> Shyam
>
Monday, March 12, 2012
Job failed with owner ()
Recently I've been seeing the following error when SQL
Server Agent jobs are run. But this doesn't always
happen, sometime the jobs run fine.
The job failed. The owner () of job xxxxxxxxxxx does not
have server access.
Any thoughts?
Is the job owned by a group that is in a Domain Local Group?
If so, you'll need this update.
825042 FIX: SQL Server Jobs That Are Owned by Non-sysadmin Users May Not
Start
http://support.microsoft.com/?id=825042
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.
Server Agent jobs are run. But this doesn't always
happen, sometime the jobs run fine.
The job failed. The owner () of job xxxxxxxxxxx does not
have server access.
Any thoughts?
Is the job owned by a group that is in a Domain Local Group?
If so, you'll need this update.
825042 FIX: SQL Server Jobs That Are Owned by Non-sysadmin Users May Not
Start
http://support.microsoft.com/?id=825042
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.
Friday, March 9, 2012
Job Execution "Failed"
Hello,
I've created one job, sometimes after the job has been
started, the job stays frozen(the job never ends). To
resolve this situation i need to restart SQL Server Agent.
I would like to develope one script or create one alert
that tell me information when this job get frozen again
but.. i dont know how. I try to check information in the
msdb..sysjobschedules but i cant do anything to reslve
this situation with the info returned.
Help me.. thanks
Best Regards
I'm not sure if there's any out of the box feature that does that, but in
case no one comes up with anything better, you could implement a log table
that tracks the progress of the package and have another package dedicated
to reading the log & sending alerts if a package takes too long. This might
be a kludge, but it would at least be flexible and allow you to check step
execution timings etc.
Regards,
Greg Linwood
SQL Server MVP
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:c0ac01c4382d$488fe490$a301280a@.phx.gbl...
> Hello,
> I've created one job, sometimes after the job has been
> started, the job stays frozen(the job never ends). To
> resolve this situation i need to restart SQL Server Agent.
> I would like to develope one script or create one alert
> that tell me information when this job get frozen again
> but.. i dont know how. I try to check information in the
> msdb..sysjobschedules but i cant do anything to reslve
> this situation with the info returned.
> Help me.. thanks
> Best Regards
I've created one job, sometimes after the job has been
started, the job stays frozen(the job never ends). To
resolve this situation i need to restart SQL Server Agent.
I would like to develope one script or create one alert
that tell me information when this job get frozen again
but.. i dont know how. I try to check information in the
msdb..sysjobschedules but i cant do anything to reslve
this situation with the info returned.
Help me.. thanks
Best Regards
I'm not sure if there's any out of the box feature that does that, but in
case no one comes up with anything better, you could implement a log table
that tracks the progress of the package and have another package dedicated
to reading the log & sending alerts if a package takes too long. This might
be a kludge, but it would at least be flexible and allow you to check step
execution timings etc.
Regards,
Greg Linwood
SQL Server MVP
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:c0ac01c4382d$488fe490$a301280a@.phx.gbl...
> Hello,
> I've created one job, sometimes after the job has been
> started, the job stays frozen(the job never ends). To
> resolve this situation i need to restart SQL Server Agent.
> I would like to develope one script or create one alert
> that tell me information when this job get frozen again
> but.. i dont know how. I try to check information in the
> msdb..sysjobschedules but i cant do anything to reslve
> this situation with the info returned.
> Help me.. thanks
> Best Regards
Monday, February 20, 2012
JDBC not connecting to SQL Server
Installing Integrity Server on MS Server 2003 but having problems when Specifing the Database, prior to this install i've already installed JDBC driver on this server version 3.
At this stage of install of the Integrity Server its trying to connect to the SQL Server (SQL Enterprise Manager V8 with SP3 on MS Server 2003)which is sitting in the same Domain. An Error appears
" A problem was encountered when trying to connect to the database JDBC.
[Microsoft][SQL Server 2000 driver for JDBC][SQL Server]Login failled
for user SA, Reason: Not associated with a trusted SQL Server
connection."
Can anyone please help
*****************************************
* This message was posted via http://www.sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...498a5488bc6539
*****************************************
Check the SQL Server. Make sure it allows SQL Server authentication in
additioin to Windows. The sign on account you are using does not relate to
an LDAP/Windows account.
"jaimoon patel via SQLMonster.com" wrote:
> Installing Integrity Server on MS Server 2003 but having problems when Specifing the Database, prior to this install i've already installed JDBC driver on this server version 3.
> At this stage of install of the Integrity Server its trying to connect to the SQL Server (SQL Enterprise Manager V8 with SP3 on MS Server 2003)which is sitting in the same Domain. An Error appears
> " A problem was encountered when trying to connect to the database JDBC.
> [Microsoft][SQL Server 2000 driver for JDBC][SQL Server]Login failled
> for user SA, Reason: Not associated with a trusted SQL Server
> connection."
> Can anyone please help
> *****************************************
> * This message was posted via http://www.sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> * http://www.sqlmonster.com/Uwe/Abuse...498a5488bc6539
> *****************************************
>
|||Thanks for that it done the trick.
*****************************************
* A copy of the whole thread can be found at:
* http://www.sqlmonster.com/Uwe/Forum...l-server/18028
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...b6c0b692a3d2fd
*****************************************
At this stage of install of the Integrity Server its trying to connect to the SQL Server (SQL Enterprise Manager V8 with SP3 on MS Server 2003)which is sitting in the same Domain. An Error appears
" A problem was encountered when trying to connect to the database JDBC.
[Microsoft][SQL Server 2000 driver for JDBC][SQL Server]Login failled
for user SA, Reason: Not associated with a trusted SQL Server
connection."
Can anyone please help
*****************************************
* This message was posted via http://www.sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...498a5488bc6539
*****************************************
Check the SQL Server. Make sure it allows SQL Server authentication in
additioin to Windows. The sign on account you are using does not relate to
an LDAP/Windows account.
"jaimoon patel via SQLMonster.com" wrote:
> Installing Integrity Server on MS Server 2003 but having problems when Specifing the Database, prior to this install i've already installed JDBC driver on this server version 3.
> At this stage of install of the Integrity Server its trying to connect to the SQL Server (SQL Enterprise Manager V8 with SP3 on MS Server 2003)which is sitting in the same Domain. An Error appears
> " A problem was encountered when trying to connect to the database JDBC.
> [Microsoft][SQL Server 2000 driver for JDBC][SQL Server]Login failled
> for user SA, Reason: Not associated with a trusted SQL Server
> connection."
> Can anyone please help
> *****************************************
> * This message was posted via http://www.sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> * http://www.sqlmonster.com/Uwe/Abuse...498a5488bc6539
> *****************************************
>
|||Thanks for that it done the trick.
*****************************************
* A copy of the whole thread can be found at:
* http://www.sqlmonster.com/Uwe/Forum...l-server/18028
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...b6c0b692a3d2fd
*****************************************
JDBC Issue with Varchar
OK..Ive successfully connected to sql server and can execute stored
procedures...if the result set is an integer it prints the result set
but has a bunch of errors:
Execute: com.microsoft.jdbc.base.BaseResultSet@.fc9944
Got from result set: 12345
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at
com.microsoft.jdbc.base.BaseCallableStatement.getA ndValidateOutParameter(Unknown
Source)
at com.microsoft.jdbc.base.BaseCallableStatement.getS tring(Unknown
Source)
at JDBC_Test.<init>(JDBC_Test.java:24)
at JDBC_Test.main(JDBC_Test.java:31)
If the result set returns a varchar I get:
Execute: com.microsoft.jdbc.base.BaseResultSet@.fc9944
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Value
can not be converted to requested type.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.base.BaseData.getInteger(Unknow n Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unkno wn Source)
at JDBC_Test.<init>(JDBC_Test.java:22)
at JDBC_Test.main(JDBC_Test.java:31)
Heres my code:
import java.sql.*;
public class JDBC_Test {
private String msDbUrl =
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=KB;selectMethod=cursor ;";
private java.sql.Connection mcDbAccess;
private CallableStatement msProcedure;
public JDBC_Test() {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
mcDbAccess = java.sql.DriverManager.getConnection( msDbUrl,
"kbuser", "password" );
msProcedure = mcDbAccess.prepareCall("{call STP_test(?)
}");
msProcedure.setInt( 1, 1);
ResultSet lrsReturn = null;
System.out.println( "Execute: " + (lrsReturn =
msProcedure.executeQuery() ) );
while( lrsReturn.next() ) {
System.out.println( "Got from result set: " +
lrsReturn.getInt( 1 ) );
}
System.out.println( "Got from stored procedure: " +
msProcedure.getString( 1 ) );
} catch( Throwable e ) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new JDBC_Test();
}
}
Jimbo wrote:
> OK..Ive successfully connected to sql server and can execute stored
> procedures...if the result set is an integer it prints the result set
> but has a bunch of errors:
Ok, and what were you expecting? When an ResultSet containing an
integer is returned, you process that and then you try to get a String
output parameter, which you did not declare as output parameter in the
first place (and probably it isn't a String either, as you pass an
integer as input value for that parameter).
In the second case your procedure returns a ResultSet containing a
character value and you try to read it using getInt()?
Alin.
|||I fixed it...sorry about all the questions..Im still learning this
stuff..thanks for all your help..now that I got the recordset
object...do you have a good link that shows me how to pass that
recordset object to a bean so I can view it in a jsp?
thanks
-Jim
procedures...if the result set is an integer it prints the result set
but has a bunch of errors:
Execute: com.microsoft.jdbc.base.BaseResultSet@.fc9944
Got from result set: 12345
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at
com.microsoft.jdbc.base.BaseCallableStatement.getA ndValidateOutParameter(Unknown
Source)
at com.microsoft.jdbc.base.BaseCallableStatement.getS tring(Unknown
Source)
at JDBC_Test.<init>(JDBC_Test.java:24)
at JDBC_Test.main(JDBC_Test.java:31)
If the result set returns a varchar I get:
Execute: com.microsoft.jdbc.base.BaseResultSet@.fc9944
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Value
can not be converted to requested type.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.base.BaseData.getInteger(Unknow n Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unkno wn Source)
at JDBC_Test.<init>(JDBC_Test.java:22)
at JDBC_Test.main(JDBC_Test.java:31)
Heres my code:
import java.sql.*;
public class JDBC_Test {
private String msDbUrl =
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=KB;selectMethod=cursor ;";
private java.sql.Connection mcDbAccess;
private CallableStatement msProcedure;
public JDBC_Test() {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
mcDbAccess = java.sql.DriverManager.getConnection( msDbUrl,
"kbuser", "password" );
msProcedure = mcDbAccess.prepareCall("{call STP_test(?)
}");
msProcedure.setInt( 1, 1);
ResultSet lrsReturn = null;
System.out.println( "Execute: " + (lrsReturn =
msProcedure.executeQuery() ) );
while( lrsReturn.next() ) {
System.out.println( "Got from result set: " +
lrsReturn.getInt( 1 ) );
}
System.out.println( "Got from stored procedure: " +
msProcedure.getString( 1 ) );
} catch( Throwable e ) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new JDBC_Test();
}
}
Jimbo wrote:
> OK..Ive successfully connected to sql server and can execute stored
> procedures...if the result set is an integer it prints the result set
> but has a bunch of errors:
Ok, and what were you expecting? When an ResultSet containing an
integer is returned, you process that and then you try to get a String
output parameter, which you did not declare as output parameter in the
first place (and probably it isn't a String either, as you pass an
integer as input value for that parameter).
In the second case your procedure returns a ResultSet containing a
character value and you try to read it using getInt()?
Alin.
|||I fixed it...sorry about all the questions..Im still learning this
stuff..thanks for all your help..now that I got the recordset
object...do you have a good link that shows me how to pass that
recordset object to a bean so I can view it in a jsp?
thanks
-Jim
Subscribe to:
Posts (Atom)