java

Transaction with two sql insert

I have two sql insert to do (say for examples in tables A and B), they are in a transaction because I want the database to remain consistent, that is, a tuple in A must have references in B. In the second insert I need the id that comes from the first, but I don't get this id until I make a commit on the transaction. So I'm stuck. I do...

How to make HttpUnit to send submit button name on form submit?

I have a single form with two submit buttons. Server side discovers proper intention by checking if submit button name is in the request parameters. Unfortunately I failed to test it with HttpUnit - looks like HttpUnit does not include the button name in the request parameters. I simulate the click by: dialog.clickButton(<button-id>) ...

how to implement a web service client which connects to an external web service with authentication based on NTLM Authentication

Hi i'm quite new in implementing web service client in java. i found a tutorial very useful...http://wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse. in my case i got 401 error: Unauthorized. It is normal as to access the wsdl i need to type the username/password. how one can do in that case? Some input on t...

WebSphere MQ Low Latency Messaging - Does it have a JMS (or JMS like) API?

We are currently using IBM MQ via JMS, but seem to be pushing through more messages than it can handle - strangely, the problem seems to be intermittent. The messages are prices and thus dont need to be guaranteed, just need to be sent quickly. As IBM have a Low Latency product, I am wondering if that is perhaps the better solution - b...

Throwing specific error messages in PLSQL Oracle...catching in hibernate?

Is it possible to throw a specific error message in a PL/SQL oracle stored procedure and catch it in Hibernate when it gets invoked? ...

Java Text Area not posting

The text area value I am trying to submit is around 400 chars and the value the servlet gets is null. When I limit this down to less that 75 chars the servlet will get the proper value. Has anyone seen this happen before? JSP <form action="/admin/homepageupdates"> <div class="body"> <textarea name="txtcontent" rows="7" cols="...

How do I create a monitor for a specific directory?

Using Java over Windows Vista, I'm trying to create a kind of a monitor for a directory, so every time this directory is modified (new, renamed, updated or deleted files) a process is triggered. I tried to do this with a loop that will execute a dir in the directory and analyze all the files. But this is very time and memory consuming, s...

Java - Storing SQL statements in an external file

Java - Storing SQL statements in an external file I am looking for a Java library/framework/technique of storing SQL statements in an external file. The support team (including DBAs) should be able to alter (slightly) the statement to keep them in sync in case database schema changes or for tuning purposes. Here are the requirements: ...

How do I center a GridView in its LinearLayout parent ?

GridView is not behaving like it is supposed to. This screenshot shows that the GridView (in landscape mode) is flushed left. I want it centered. This is the XML layout for the GridView. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/templatelandscape" android:orientation="horizontal" ...

Howto make a function "timeoutable" in Java?

private String indexPage(URL currentPage) throws IOException { String content = ""; is = currentPage.openStream(); content = new Scanner( is ).useDelimiter( "\\Z" ).next(); return content; } This is my function with which I'm currently crawling webpages. The function that a problem is: content = new Scanner( is ).useD...

On the non-extendability of Commons Lang ReflectionToStringBuilder

This goes to the fact that you cannot extend a class with no no-arg constructor in Java. The canonical use for ReflectionToStringBuilder is as follows public String toString() { return (new ReflectionToStringBuilder(this) { protected boolean accept(Field f) { return super.accept(f) && !f.getName().equals("pass...

How to read data from an XML file and store it into database (MySQL)?

I need to get data from an XML file and store it into a MySQL Database. I am thinking of using a SAX Parser for parsing the data but I am not sure of how to store data efficiently into database, I am thinking of few technologies like JDBC and Hibernate but I wanted to ask about what would be the efficient way of doing it? Note: Here pro...

SEAM ENTITYQUERY - Problems with Restriction seam-gem example

My project was originally generated by seam-gen and the action "List" bean is not working as i expected. The restriction array has all the attributes from table and is behaving as if all the parameter were mandatory. See the List Bellow: package br.com.autenticis.comvenif_red_web.session; import br.com.autenticis.comvenif_red_web.entit...

Multiple read from an InputStream at different rates

I'm about to load an online content (say an audio file). If I just open a connection to the remote file (for example by use of new URL().openStream()) and pass the remote InputStream to the audio player, it reads gradually from the network. If audio player library do not ask InputStream for more data, it reads nothing from the network, a...

Create Outlook task with Java.

I have a requirement to have a new task appear in a user's task list in Outlook. The catch is that the source of the task will be generated in a Java environment. Does anyone know how I can create an Outlook task using Java? Thanks. ...

Java and SQL : return null or throw exception?

This is another debated subject, but this time i am searching only for the simple and documented answers. The scenario : Let's assume the following method: public static Hashtable<Long, Dog> getSomeDogs(String colName, String colValue) { Hashtable<Long, Dog> result = new Hashtable<Long, Dog>(); StringBuffer sql = null; Dog dog...

Java Scanner Headache

I have a text file which looks like: name1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 0 name2 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 i.e., a plaintext label followed by a few rows with 1/0 separated by spaces. The number of rows of 1/0 is variable, but each row between any two particular labels should have the same number of 1/0s (though might potentially n...

JAXB Collections (List<T>) Use Pascal Case instead of Camel Case for Element Names

Hi All, I have a number of JAXB beans that are directly marshalled and unmarshalled using Jersey. E.g. @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Artifact", propOrder = { "artifactId", "artifactType", "contentHash" }) @XmlSeeAlso({ EmailArtifact.class, ManagedDocArtifact.class }) @XmlRootElement(name ="...

using java regex how can I replace all when pattern contains left parenthesis

I have a string that looks like this: "mynum(1234) and mynum( 123) and mynum ( 12345 ) and lastly mynum(#123)" I want to insert a "#" in front of the numbers in parenthesis so I have: "mynum(#1234) and mynum( #123) and mynum ( #12345 ) and lastly mynum(#123)" How can I do this? Using regex pattern matcher and a replaceAll chokes on ...

How to use svnClientAdapter java API getLogMessages(java.io.File path, SVNRevision revisionStart, SVNRevision revisionEnd)

I just want to get all the log messages for a given resource in the repository. However, given this particular API, I get errors if I try to specify the start revision as SVNRevision.START and the end revision as SVNRevision.HEAD Interestingly enough, the cmd line client has the same problem: $ svn log --revision START:HEAD fileName ...