Kevin Bolton

Greenhorn
+ Follow
since Nov 20, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kevin Bolton

How do I get a handle to the Fax Monitor null servlet from the doGet method of the servlet that sends the fax?
22 years ago
I have a JSP page that allows the users to send a fax (scheduled and processed on another machine). The users want an email confirmation when their fax is done. So, when the user submits at fax, I give the fax to a FaxMonitor class that periodically checks the fax's status. When it is done, it sends an email to the user.
The FaxMonitor is Runnable and presently expects external code to put it in a Thread and start it. This could be changed to where it's constructor could do this.
I would like there to be one and only one instance of the FaxMonitor. It should be created either on startup or on first use. Once created, it should hang around virtually forever.
I'd like the one instance to be in the same JVM as the servlets so that I don't need to Serialize/Remote my code.
How should I do this?
22 years ago
been there - read that. On the other hand, I uninstalled forte, removed the registry entries, and reinstalled forte. When it starts for the first time, forte asks for the place to store your personal files. I think I've misunderstood how this is used. In any event, I told it the directory forte was installed in. With that, I was able to complete the junit installation and have junit working. Thanks.
22 years ago
I've just installed forte 3.0 CE and would like to use JUnit testing. I downloaded JUnit 3.7 nbm file and installed it in forte. Forte recognized the module to some extent as the settings and menu choices are there for it. These even work. I was able to generate a test class.
But it wont compile. The netbeans intallation page for JUnit speaks of mounting the JUnit frame work supposedly located in the lib/ext directory and yet I cannot find any junit files (jars or other) there.
Anyone have better instructions on installing and using JUnit?
22 years ago
Yes I suppose I would in a multi-threaded app. So I'll keep that in mind when I convert over. Perhaps the cost of synchronizing the preparedStatement will outweigh the benefit of it.
I'm looking at PoolMan currently. An associate turned me onto it. PoolMan supposedly provides connection pooling and PreparedStatement pooling. So perhaps I will have the benefit of prepared statements without worring about synchronizing the prepared statement.
I could think of other ways to hold onto the PreparedStatement in a non-static way, e.g a hashtable in another class. I still wouldn't know when I could close the PreparedStatements. I suppose I could use a thread to close PreparedStatements that haven't been used in a while. Any better ideas?
I ran this performance test showing that using a PreparedStatement was roughly 2.5x - 3.0x faster than creating the query each time:
private static void testQueries(Connection connection)
throws SQLException {
int numberOfRuns = 50;
//try regular statements - created and closed each time
long startTime = System.currentTimeMillis();
for(int i = 0; i < numberOfRuns; i++) {
ResultSet resultSet = executeQuery(connection,
"select ct.new_account_number "
+ "from dang0.customertypes@cmsm ct, dang0.customers@cmsm c "
+ "where ct.account_number = c.account_number "
+ "and c.status = 'A' "
+ "and rownum <= 100");
resultSet.getStatement().close();
}
System.out.println("Regular statements took " + (System.currentTimeMillis() - startTime));
//try creating and deleting preparedStatements
startTime = System.currentTimeMillis();
for(int i = 0; i < numberOfRuns; i++) {
PreparedStatement preparedStatement = connection.prepareStatement(
"select ct.new_account_number "
+ "from dang0.customertypes@cmsm ct, dang0.customers@cmsm c "
+ "where ct.account_number = c.account_number "
+ "and c.status = 'A' "
+ "and rownum <= ?");
preparedStatement.setInt(1,100);
ResultSet resultSet = preparedStatement.executeQuery();
preparedStatement.close();
}
System.out.println("Prepared statements took " + (System.currentTimeMillis() - startTime));
//try reusing 1 prepared statement
startTime = System.currentTimeMillis();
PreparedStatement preparedStatement
= createAndStorePreparedStatement("com.mpowercom.util.SQLTools.test",
connection,
"select ct.new_account_number "
+ "from dang0.customertypes@cmsm ct, dang0.customers@cmsm c "
+ "where ct.account_number = c.account_number "
+ "and c.status = 'A' "
+ "and rownum <= ?");
for(int i = 0; i < numberOfRuns; i++) {
preparedStatement.setInt(1,100);
ResultSet resultSet = preparedStatement.executeQuery();
}
preparedStatement.close();
System.out.println("1 Prepared execute took " + (System.currentTimeMillis() - startTime));
}
and got:
Regular statements took 27410
Prepared statements took 27570
1 Prepared execute took 9340
I would like to share a preparedStatement across instances of a class.
e.g. static PreparedStatement preparedStatement = someStaticConnection.prepareStatement(someSql);
The preparedStatement will be opened when the class is loaded. Many instances use the prepared statement. But, where would I put code to close the connection? Does the class ever get unloaded?