Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method calling

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i m facing a urgent problem which i have to show to boss...
the problem that is comming is...calling method

"getConnection(String)

which in details is as follow


public Connection getConnection(String dbasename)
{

String userName = "sa";
String password = "sa";

Connection con =null;

String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url= "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName="+dbasename;
try
{
Class.forName(dbDriver);
con = DriverManager.getConnection(url,userName,password);
}
catch(Exception e)
{
System.out.println("Exception caught "+e);
e.printStackTrace();
}
return con;

}




This method making a connection with mssql2k server and returning the Connection object..

when i call this method by passing String like
getConnection("employee");


where "employee" is the name of the database.
everything is working fine
but when i m passing the variable object as String like

String database = request.getParameter("db");
where db has "employee" value

and calling the method getConnection(database);
nothing is working

pls pls can anybody tell why this is happening
its really urgent and i have to show to my boss

thanx in advance ..

regards,
amit taneja

[Bear edit: not so urgent]
[ December 21, 2004: Message edited by: Bear Bibeault ]
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error page show is

The page cannot be displayed

HTTP 500 - Internal server error
Internet Explorer


pls tell me what to do ???

can anybody tell me why the error is comming ?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not urgent, may look into it sometime next year.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit taneja:
The error page show is

The page cannot be displayed

HTTP 500 - Internal server error
Internet Explorer


pls tell me what to do ???


May be the server is waiting for the connection object for a long time, since it dint get the connection for a long time you are getting this.

I got the same type of Exception when a call was made to a external application through API. That application does some DB related stuff, there was some connection pool error ( may be the number of open connections exceeded the maxiumum limit ) the JSP was waiting for some time & i got this page even though isErrorPage is set to an error page.
 
Nitin Jawarkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Amit,

It may occur due to u r server reponce time.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though I tend to agree with Jeroen with regards to the title of this post, you will need to read the "Internal server error" to have any hope of progressing. It will be being logged on the server console or to a file (consult your Servlet container's documentation if you are not sure). You could also set your browser to show more than just friendly error messages (again, read the docs). There are a number of reasons why your code might be failing but none are obvious from what you've posted so far.
[ December 21, 2004: Message edited by: Paul Sturrock ]
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i m sure thsi is not the error...... as ppl did'nt understand the problemm... see
i m saying that getConnections is working fine when u sing as

getConnection("employee");

but not when using as

getConnection(Stringvariable);

where Stringvariable is containg the value "employee" thats it..
there is no correlation of server late reponse time ... and if that is the case then the program shouldn't run fine in any case..

see here i m using variable because i putting value to
Stringvariable=request.getParameter("some_name_of_other_html_field");

thats it...

i will appreciate any logical answer

thanx


Regards,
Amit
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you get
The page cannot be displayed

HTTP 500 - Internal server error
Internet Explorer

There is almost certainly a log entry somewhere that was written when that error occurred.
You should also turn off the accursed "Friendly Http error message" setting on your MSIE (tools -> internet options -> advanced ->browsing) - perhaps the server is actually sending a useful error message.
(why do people think that a post title "very urgent.." gets more attention than a title that summarizes the problem??)
Bill
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you are still not making this easy amit taneja, since you still have not told us the exception you are seeing which is the method Java uses to tell a programmer what is wrong, but I would guess that (since you don't check for it) the database name could well be null or a non-existant database.

If you posted the exception, I (or someone else) would possibly be able to tell you for sure.
[ December 21, 2004: Message edited by: Paul Sturrock ]
 
Sandeep Deshmukh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi amit

I think you must put a log like System.out.println(request.getParameter("db"));
before you pass it to your getConnection() so that you can check correctness of response recieved.
You may get error but as you have put the logs you will find answer to what may be wrong.

Best of luck.

Sandeep
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic