Originally posted by Peter Chase:
Eclipse is written in Java, isn't it? Are you sure you didn't attach to Eclipse itself?
Originally posted by Peter Chase:
In Visual Studio 2005, use the Tools menu, Attach To Process. Look for the java.exe process.
It's in the Tools menu of VS 2003, as well, as Debug Processes.
Originally posted by Peter Chase:
I don't use Visual Studio for developing my native libraries, just occasionally for debugging them.
When you say you set the Command to "java", did you include the full path to the Java executable? If not, I think you should, as there could be more than one Java on your machine.
As for Visual Studio crashing, contact your debugger vendor
How about trying attaching Visual Studio to your running Java process, rather than launching Java from Visual Studio? Does that work?
Originally posted by Peter Chase:
(bartender: I thought JNI was supposed to go in Other APIs. It says Other APIs including JNI)
Anyway...
I don't know of any single tool that can seamlessly debugs Java and native C/C++ code. That doesn't mean that it doesn't exist. In my organisation, we mostly use built-in or free command-line tools - not big on IDEs (unless emacs counts) or buying expensive tools - so there may be some premium product out there that I don't know about.
You certainly can use an ordinary C debugger to debug the C/C++ code that forms your JNI library.
First, make sure it's built with the necessary debug information included (compiler/linker switches).
Then run your Java launcher (e.g. "java[.exe]") in a C/C++ debugger. You can use gdb on Unix or Mac OS X. Or you can use Visual Studio (spit) or WinDBG (yea) on Windows.
You won't get many debugging facilities on the code of the JVM itself, as it has no debug symbols. But once your native library has loaded, you can set breakpoints on your JNI functions, see variable values, examine call stack, catch C++ exceptions etc.
This said, I agree with the previous responder who recommended keeping the C/C++ code as simple as possible and putting the complicated stuff in Java. The C/C++ should be just sufficient to interface with the native facilities you're using. That is assuming you're using JNI for accessing native facilities, rather than for performance; the latter is much less necessary these days, because the latest JVMs are so fast (faster than C, in some cases).
If you need to debug Java and C/C++ in the same session, you can run "jdb[.exe]" (rather than "java[.exe]") in the C/C++ debugger. Works fine ... honest.
Final point: if it's difficult to adjust your Java start-up to run via C/C++ debugger, you can use your ordinary start-up procedure, then attach the C/C++ debugger to the Java process.
[ August 13, 2007: Message edited by: Peter Chase ]
Originally posted by marc weber:
I think JNI is a bit advanced for the beginners forum. Let's promote this to the intermediate forum.
Originally posted by Remko Strating:
I already told you I did a simple test and it worked. I could get a string from an integer,bit,blob field.
Why don't you try it yourself.
Originally posted by Stan James:
I've done this very thing. I made a Key object that holds an array of values and implements Comparable. You tell it which columns to use for keys, and it assumes that both result sets are in ascending order.
Just looking at it, I used getString() for all columns. I wonder how I didn't get burned by "10".compareTo("2"). Maybe I just got lucky? In the reporting phase I check to see if the column type should be right justified, so I do line up 2 and 10 correctly there.
If you figure out which columns won't work as String and get a good comparable key, the basic algorithm I drag out often is:
Note that a key at end always compares as larger. For my purposes, when the keys match, I optionally do another comparison on all the rest of the columns.
Any of that sound helpful?
[ August 09, 2007: Message edited by: Stan James ]
Originally posted by Remko Strating:
If you want to compare if the rows are equal. You could just use getString() for every field and then add the values of the different fields to one string and compare this string with an another row-string.
I've tested this with a simple table and query and it worked. For a good working you have to order your table first.
But what database are you using. It could be that your database has a better solution for comparing two tables.
Originally posted by Remko Strating:
I don't know what you exactly mean but have a look at the following url
ResultSet MetaData
With this class you can retrieve metadata of your resultset and this you could use for writing a generic method.
Originally posted by Ulf Dittmer:
If it gets in the way of compiling, you can safely delete it from the source without fear of runtime consequences.
Originally posted by John Bartlett:
Hi,
if you take a look at @Override it states it has been available since J2SE 5.0 so you'll need the JDK5.0 or higher.
John
[ July 25, 2007: Message edited by: John Bartlett ]