• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.sql.SQLException: Server configuration denies access to data source

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote the following class DBManager to access the mySQL DB server from java programs.

And use it in the following way:

Is there any problem in this approach?
Will the connection created in getQueryResultSet() closed automatically after I call this method?
There seems to be a limit on the number of available connections. As my program query the DB using the above approach continously, I am concerned whether the available connections would be exhausted. I started my program this afternoon and went out for a hour or so, when I came back, I found the following error message:

What could be the reason of this error?
To see whether it's the problem of connections, I wrote the following code to test it,

And it didn't generate any error so far: the count is already 68000!
I am confused. Anybody can help me?
Thanks.
[ January 14, 2004: Message edited by: W Sun ]
[ January 14, 2004: Message edited by: W Sun ]
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would be interested to know what's the deal also.
I haven't had that problem.
What is you system config?
I would pre-pend each of you sql exceptions with specific word to capture where exactly the error occured. The SQLException error messages(some) are a bit vague.
Example System.out.println("SELECT Error: " + sqle);
Example System.out.println("CONNECT Error: " + sqle);
Why are you leaving all those connections open anyway?
 
W Sun
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jason.
I was trying to use a piece of simple code to get query result from the DB, and WISH the connection created by calling
resultSet = new DBManager().statement.executeQuery(querySQL);
is temporary and would be closed automatically when the call is finished. But if I rewrite the method getQueryResultSet like the following, the returned result set is not accessible because the connection is closed.(believe it, I tried it.)

I guess the right way to do this is:
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in this piece:

line 5 should have been:
resultSet = dbManager.statement.executeQuery(querySQL);
I haven't tried it, but I think that's why the connection was closed
I would like to share my wrapper with you:
Note: It's not completed, but it works

I call it like this:

This sets up a persistent connection that will last the life of the app.
Further, if you want to switch databases or users, you can do that with the setter methods and then call renewConnection()
You can add/change/delete how you see fit if you want to...It's young is intended that at completion, it will support most DB Servers.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic