Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make use of C# System.DBNull.value in Java?

Tags:

java

c#

com

I'm translating some code written in C# to Java. This code uses COM objects to interact with a third party application. I managed to handle COM objects using com4j library, but one of the methods requires System.DBNull.value to be passed into it which is a C# object.

How can I handle it from a Java application?

like image 743
svz Avatar asked Apr 30 '13 13:04

svz


People also ask

How do I use C on my computer?

It is a bit more cryptic in its style than some other languages, but you get beyond that fairly quickly. C is what is called a compiled language. This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute).

How is C used in everyday life?

C programming language is majorly used in the creation of hardware devices, operating systems, drivers, kernels, etc. It is also used for the development of GUIs and IDEs. For example: Linux Kernel is written in the C language.


1 Answers

.NET System.DBNull is equivalent to a VARIANT of type VT_NULL. In fact this is documented officially here: DBNull Class

So I suppose using com4j you can create a Variant, call setType(VT_NULL), and pass this to the .NET interop layer.

like image 159
Simon Mourier Avatar answered Oct 04 '22 01:10

Simon Mourier