Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Johann Dobbins

Ranch Hand
+ Follow
since Oct 16, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Johann Dobbins

My task is to parse a large mssql table into a csv file, to be uploaded elsewhere. This needs to occur on a scheduled basis (daily, but should be configurable), and the task should be able to be executed on the click of a button on a webpage.

It would be non-ideal to install and maintain Tomcat or any other web/application server to run a Java program, because these are not currently available and they probably have unnecessary overhead.

My thought is that I would just write my database querying, csv converting, file uploading, (business logic, etc) in Java, package it up in a jar, and stick it somewhere my Jenkins server can get to (I have access to a Jenkins installation). Then I would just configure a Jenkins job to execute the main method as a shell command on a scheduled basis. And then when the web page button is pushed, I could create a Jenkins job (in php or whatever) to execute the main method a single time.

This seems easy to implement and maintain. Are there any obvious pitfalls here that I'm unaware of? Is this a misuse of Jenkins? Any input on other implementation strategies, or ways to improve the one I propose?

Also, any advice on how to create a csv from a large mssql table, in a time efficicent and memory safe manner, would be greatly appreciated.

6 years ago
I am trying to allow users to draw smooth line on a touchscreen with their finger. I initialize a list of vertices when the finger touches the screen, and set this point as the initial vertex. As touchMoved events occurs, I add the x,y for the move event to the list of vertices if its distance from the previous vertex in the list is greater than threshhold (currently using 5 (pixels)). Rendering the line by simply connecting each vertex with a straight line actually looks ok, but it is too rough (as in not smooth).

I used source code I found here to smooth the line with interpolation: Unfortunately these solution are not an option because they involve adding a significant number of vertices to my vertex list. Despite the use of threshhold when compiling this list, the list easily becomes a few hundred vertices large as the user drags their finger back and forth, so multiplying this list by 10x (which the interpolation does) is not an option for performance reason.

I tried the algorithm discussed here: But it barely improved upon connecting vertices with straight lines.

The method discussed here seems like what I need: However, I'm not familiar with the math used so I haven't been able to implement the algorithm in this discussion.

Is anyone aware of a java implementation of the Curve Global Approximation discussed in the above link, or another method to accomplish this?
9 years ago
I am trying to connect to a Sharepoint server through Java code. My code works fine with some Sharepoint servers, but fails when I try to connect to my Comcast provided account. The classes `ListsSoap` and `Lists` were generated from a Sharepoint WSDL using wsimport.

I read this may be caused by not using doman\username as the Sharepoint username. I tried prepending different domains to the username parameter, things like "\\"; but I received a 401 error for all domain names I tried. Failed to access the WSDL at:
It failed with:
Server redirected too many times (20).

10 years ago
If I set a key accelerator for a JMenuItem, and type that accelerator in a textfield, the typing gets outputted to the textfield and then the key accelerator occurs. For example, if I set shift+c as a key accelerator, then type shift+c in a textfield, I will get a capital 'C' in the textfield and the associated JMenuItem action will occur. Are there any parameters that I can use when setting this accelerator or any workaround I can use to prevent the accelerator from occurring and the textfield from losing focuses? I would rather not have to implement a workaround involving listeners for the textfield, because this would would require refactoring all code pertaining to textfields in my app.
11 years ago

Campbell Ritchie wrote:Don't know, I am afraid.

Lol. Thanks. I didn't particularly expect a solution.
11 years ago

Campbell Ritchie wrote:Agree that killing and stopping threads is dangerous.

There are all sorts of things you need to consider, and ought to tell us before deciding, eg

  • Where are you uploading from?
  • Is your method suitable for such an upload?
  • Is your method principally designed for uploads of different sizes or from different locations?
  • Do you have to open and close Sockets or similar?
  • Can you find a different uploading method?
  • Can you start a Thread which handles the upload, and throw an Exception in that Thread to cancel it?

  • The whole thing might be very complicated.

    Where are you uploading from? Not sure what you mean, users will be uploading from my app on their machine.
    Is your method suitable for such an upload? The method provided by the api? Yes, it is suitable, other than the lack of a cancel.
    Is your method principally designed for uploads of different sizes or from different locations? It can handle uploads of any size, not sure what is meant by "different locations"
    Do you have to open and close Sockets or similar? I'm not positive what the api is doing, I assume it is making webservices calls, so I'm going to say no.
    Can you find a different uploading method? No, for maintenance purposes, I am required to use the provided api.
    Can you start a Thread which handles the upload, and throw an Excpetion in that Thread to cancel it? I don't think so. Since I have no access to the api code, I can not write any logic to receive and handle an Exception.
    11 years ago
    I am making a call to an api, which handles the uploading of a file. I would like to be able to cancel the upload upon user request. But, the api is poorly implemented, it does not expose an sort of a cancel method. Once the upload is started, there is no way to force it stop. Any suggestions about what I could do?

    What makes some sense to me is to do something along the lines of making the upload call in a thread, keeping a reference to the thread, and killing upon user request. But, according to the java api, this is a bad idea:

    Deprecated. This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.

    Modifying a global variable doesn't get me anywhere. Because the upload is happening inside the api, which is code that I can not modify. Help please?

    Thank you
    11 years ago

    Jesper Young wrote:

    Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.

    Parsing means converting a String to a Date. The opposite, converting a Date to a String, is formatting.

    So you can't "parse a date string into format X" - you parse a String with a format X into a Date object, or you format a Date object into a String with format X.

    Thank you for your help.
    11 years ago

    Rob Prime wrote:

    Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.

    Dates have no formatting of their own, so you would need two DateFormats for this: one for parsing, one for formatting. Although if you know the Date to format you can also use java.util.Calendar to create the Date:

    excellent, thank you
    11 years ago

    John de Michele wrote:Johann:

    You're missing a time zone.


    Sorry? I'm missing a time zone in the string I'm trying to parse?

    That string is actually dynamic, I just wrote it has hardcoded for clarity. In the dynamic string, no time zone is given. I thought if no time zone was present, the date parser would use the local time zone?
    11 years ago
    I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.

    The below code gives exception: java.text.ParseException: Unparseable date: "2010-04-28 07:48:19"

    Help please?
    11 years ago

    Ulf Dittmer wrote:

    It seems I would want to configure fiddler to listen to requests FROM a certain port on my client machine?

    No. The port from which the request is sent is likely different on every single call. The way proxies work is that the client software accesses the proxy instead of the server, and then the proxy forwards the request to the server. So you should alter the client to access port 8088, and then run Fiddler to listen on port 8088 and forward to port 80.

    My client is currently calling testserver:80. And I should change my client to call localhost:8088. And then set Fiddler to forward to testserver:80? Any chance you are familiar with fiddler and can advise how to set up this forwarding? I've been looking through documentation, but have been unable to find an example of how to do this.
    11 years ago

    Ulf Dittmer wrote:It's not what port Java uses, it's what port the piece of software uses. For web services, you'd generally pass in the URL, which contains the port (unless it's the default port 80). If you're not explicitly passing in the URL, have a look through the source code of the stubs you're using - the URL (and the port) are bound to be in there.

    The piece of software? meaning the webserivce? the webservice is running on port 80, I have tried configuring Fiddler to listen on port 80, but to no avail. It seems I would want to configure fiddler to listen to requests FROM a certain port on my client machine?
    11 years ago
    I am using java stubs to make calls to a web service and would like to capture the actually soap requests for debugging purposes. I am trying to use Fiddler2. But none of my requests from java code are captured in Fiddler2. I assume this is because my Fiddler2 is configured to listen for requests on port 8088, which I assume is not the port being used by java. What port does java use?

    Thank you.
    11 years ago
    I have a component that extends JTextField. It uses a mouselistener to show a context menu on a right click. The context menu has commands like "cut, copy, paste", all of which have logic based on the selected text. This works fine on windows, but on mac, the right click de-selects the selected text. Anyone know of a workaround?

    *note, the text is deselected on a right click even if i replace my logic with:

    11 years ago