It seems that every time I want to perform a db query, I have to write the following:
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
conn = dataSource.getConnection();
stmt = conn.prepareStatement(sql);
// ...set stmt params
rset = stmt.executeQuery();
while(rset.next()) {
// Do ...
How do I get a Java Class's variable which is dynamically modified from an applet.
The problem here is since the applet is loaded in separate class loaders the updated value is not available when the applet is loaded a second and subsequent times.
...
Hi
I'm having a problem. I would like to create Document object, and I would like to have a user property with com.google.appengine.api.users.User type (on GAE's docs site, they said we should use this object instead of email address or something else, because this object probably will be enchanced to be unique). But now the object can'...
Hi all,
I'm using an Ant build script to collate my Eclipse-based application for distribution.
One step of the build is to check that the correct libraries are present in the build folders. I currently use the Ant command for this. Unfortunately, I have to amend the script each time I switch to a new Eclipse build (since the version...
I've got an application that parses log files and inserts a huge amount of data into database. It's written in Java and talks to a MySQL database over JDBC. I've experimented with different ways to insert the data to find the fastest for my particular use case. The one that currently seems to be the best performer is to issue an extende...
Hi, I am trying to write a simple program to open a socket channel to a local address. I get a connection refused exception whenever I run this program
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
public class testSocket {
public static void main(String [] args) {
...
My question is very related to this one: http://stackoverflow.com/questions/932625/multiple-dynamic-data-sources-for-a-servlet-context. However I haven’t found a proper solution just yet and would like to ask it again.
I have a little JSF application that talks to a MS SQL Server via JDBC. Tomcat is used as the web container. The applic...
Someone else's process is creating a CSV file by appending a line at a time to it, as events occur. I have no control over the file format or the other process, but I know it will only append.
In a Java program, I would like to monitor this file, and when a line is appended read the new line and react according to the contents. Ignore ...
Is there a built-in data structure in Java to represent a Crit-bit tree? Or any libraries available that might provide this functionality? I would also accept brief code as an answer, if one can be implemented in a simplistic brief way.
...
In Java, is it possible to clear a bit using bitwise operations?
...
Is System.currentTimeMillis() the best measure of time performance in Java? Are there any gotcha's when using this to compare the time before action is taken to the time after the action is taken? Is there a better alternative?
...
This may be something common and trivial, but I seem to be having trouble finding a concrete answer. In C# there is a concept of delegates, which relates strongly to the idea of function pointers from C++. Is there a similar functionality in Java? Given that pointers are somewhat absent, what is the best way about this? And to be clear, ...
I am using RandomAccessFile to perform some writes to a file as part of a transaction. Before I commit my transaction, I want to be absolutely sure that the data is written to disk.
Calling force(boolean) on the RAF's FileChannel appears to provide this guarantee, but is it called implicitly when I close the file, or do I have to call ...
My build.xml is building successfully.But it is not creating or copying all the folders and files. It took only 1 sec for building. I think it have to to round about 1 min. I tried to find out whats wrong by giving echo in different point. I could see that when I put echo somewhere it show the message in the echo two time,somewhere it is...
I have recently started using DocCheck for checking the validity of JavaDoc's in code files.
Is there some way to set DocCheck up as an eclipse plugin?
...
I have a project which is build through maven. Each module is built as an osgi bundle.
Within Eclipse the modules have also the plugin nature. Some modules require external dependencies (log4j, apache commons, ...), which are also available as plugins from a maven repository (for instance the spring enterprise repository, which is also...
Hi all.
I asked a question some time ago on java 2d pathfinding...
http://stackoverflow.com/questions/735523/pathfinding-2d-java-game
The game im developing is based on the idea of theme hospital.
The chosen answer from my question, A* pathfinding, the link was awesome, and very helpful.
I'm eventually getting to implement this into my ...
I am trying to add an entry to an LDAP server using JNDI. I could successfully read the entries from the LDAP server. But when I try to add a new entry I am getting the errors. I checked various ways but I failed.
private String getUserAttribs (String searchAttribValue) throws NamingException{
SearchControls ctls = new SearchContro...
I am in the process of evaluating FindBugs and am trying to make use of the excludeFilter so that the tool does not process the test packages or the generated ejb stubs.
I have tried the following:
<FindBugsFilter>
<!-- Match any test packages -->
<Match>
<Package name="~.*\.test"/>
</Match>
<Match>
<Or>
<Class name="~.*\....
I have a client currently thinking about using SeeBeyond / Sun's JCAPS product, does anyone on SO have any positive or negative experiences using / developing for it ?
...