GeeCON Prague 2014*
The moose likes JDBC and the fly likes Stored proc not found... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Stored proc not found..." Watch "Stored proc not found..." New topic
Author

Stored proc not found...

Kingsley Mullers
Ranch Hand

Joined: Jan 14, 2005
Posts: 48
Hi there,

I�ve finally managed to connect to SQL Server but the problem is that the stored procedure is not found whereas it does exists, is there anything that I might have omitted that�s causing this type of error, I�ve specified the full path but no success,
---------------------------------------------------------------------------
my code looks like this..

import java.sql.*;
import com.microsoft.jdbc.sqlserver.*;
import com.microsoft.jdbc.*;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
* Microsoft SQL Server JDBC
*/
public class PhoneBookDetails {
// Get connection
// DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
public Connection getConnection(){
Connection connection=null;
try{
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
Class.forName(driverName);
String username="fido";
String password="odif";
String databasename="RSAPORTAL";
String url="jdbc:microsoft:sqlserver://SERVERNAME:0000;
databasename= data_base_name;username=username;password=password";
connection=DriverManager.getConnection(url,username,password);

}catch(ClassNotFoundException e)
{
System.out.println("ClassNotFoundException");

}catch(SQLException e){
System.out.println("Exception" +e);
}
return connection;
}

public String getPhoneBookDetails(Connection connection,String Username)
{
String details="";
try{
CallableStatement callableStatement =connection.prepareCall("{call getHR_PhoneBookEntryByUsername ?}");
callableStatement.setString(1,Username);
ResultSet resultSet = callableStatement.executeQuery();
if(resultSet.next())
{
System.out.println("usernameDetail 1 " + resultSet.getString(2));
System.out.println("usernameDetail 2 " + resultSet.getString(3));
System.out.println("usernameDetail 3 " + resultSet.getString(4));
System.out.println("usernameDetail 4 " + resultSet.getString(5));
System.out.println("usernameDetail 5 " + resultSet.getString(6));
System.out.println("usernameDetail 6 " + resultSet.getString(7));
System.out.println("usernameDetail 7 " + resultSet.getString(8));
System.out.println("usernameDetail 8 " + resultSet.getString(9));
System.out.println("usernameDetail 9 " + resultSet.getString(10));
System.out.println("usernameDetail 10 " + resultSet.getString(11));
System.out.println("usernameDetail 11 " + resultSet.getString(12));
System.out.println("usernameDetail 12 " + resultSet.getString(13));
System.out.println("usernameDetail 13 " + resultSet.getString(14));
System.out.println("usernameDetail 14 " + resultSet.getString(15));

}
}catch(Exception e){
System.out.println("Exception" +e);
}
return details;
}
public void closeConnection(Connection cn){

try{

if (cn != null)
cn.close();
cn=null;
}catch(Exception e){
e.printStackTrace();
}
}
public static void main (String args[]) throws Exception
{
PhoneBookDetails test = new PhoneBookDetails();
Connection c=test.getConnection();

if(c==null)
{
System.out.println("Connection is null...");
}else
{
String x =test.getPhoneBookDetails(c, "Mwelas_m");
System.out.println("Connection is successful...!!!");
}
test.closeConnection(c);
}
}
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
Try prefixing the strored procedure name with the owner name. for instance, if the owner is 'dbo', call it as dbo.getHR_PhoneBookEntryByUsername


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Kingsley Mullers
Ranch Hand

Joined: Jan 14, 2005
Posts: 48
thanks for the response, i've tried that, cos the store proc above it has dbo, but this one i'm calling has fido in front of it but still no luck...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Stored proc not found...