Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC ODBC not connecting 1

Status
Not open for further replies.

oaklandar

Technical User
Feb 12, 2004
246
US
I had a Access 2000 database connection working on IIS on Windows 2000 that is using a JSP engine. Everything worked with my databases until this morning.

Now all of a suddent I get and error message on my JSP action page:
Code:
[Microsoft][ODBC Microsoft Access Driver] System Resource exceeded.

I am using this connection object:
Code:
Connection connection = DriverManager.getConnection("jdbc:odbc:myDatabaseName", "", "");

Now if I change the action page to a Cold Fusion page where I use a Cold Fusion ODBC it works.

What can I do to correct the JSP JDBC on the server? Are there any settings that can be reset? It seems to give me the error message on all my databases with JSP.
 
Thanks again that solved my problem.

I will now close my objects.
That I assume also means closing any String objects I open such as?

Code:
String name = request.getParameter("Name");

name.close();
 
Closing objects is all about garbage collection, and the impact of leaving objects open against other resources.

When you are in a function/method, if an object is declared inside a function/method, such as a String or a primitive like an int, float, double etc, you do not need to close/destroy the object because the JVM will deal with it.
The difference is that when you open an object against an external resource, garbage collection (GC) will not ever kick in. Not only that, but you will leave dead objects on the resource you are connecting to.

Example, when connecting to a database.

When you do -

Connection c = ...
This creates a network connection to a remote server. If you do not close it, the connection will eventually time out, and disconnect itself, if you are lucky, but it is using up valuable network slots.
When you do a "Statement s = conn.getStatement()" it is creating an execution plan on the db,using resources, and if you do not call "close()" on this object the db may keep this plan open forever - using up valuable resources.
The worst type is ResultSet. This opens a CURSOR against a db - which is an object that maintains its execution plan, and network connection against a database. Even when a network connection dies and times out (into TCP TIME_OUT), the cursor (in most db's) remains open. Eventually, if this behaviour continues, you will completely shag the database.

You need to understand what your code is doing, and what EXACTLY it is doing, and inderstand the consequences if you don't clean up after yourself.

A lo of people say "C/C++ is harder then Java because Java cleans up after itself". This is IMO a false assumption. In certain cases, Java will free memeory that C would not, but it leads people into a false sense of security - Java is not a scripting language whereby all statements are arbitrary - if you leave a networked object open, then you will experience not only a memory leak, but a serious problem.

Understand the basics - don't everything for granted, but also understand that if you declare a variable in a method, it will dies after the mehtod has exited.

IMO, you need to understand exactly how memory and resource allocation works in Java/C/C++ in order to fully write bullet-proof code.

--------------------------------------------------
Free Database Connection Pooling Software
 
with all that being said, sedj, at what point would you start using connection pooling?
 
zeero:

I would start to look at connection pooling when you start hitting a db more than 5 or 10 times a minute, ish. Having said that, if it is important to have connections ready as quick as possibly, I would use pooling straight off, because it is just quicker at obtaining a connection than the non-pooled way.


--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top