Skip to main content

Posts

Showing posts with the label C

Easy Start with JNA

JNA (Java Native Access) is the good and easy answer to the JNI(Java Native Interface). Those who find it cumbersome to to call C, C++ DLL functions using JNI, then JNA is for you. The project is hosted at https://jna.dev.java.net/ . Here is my first encounter(experiment) with the JNA. Problem: I want to call one DLL function in Java program Solution: The first thing that comes into my mind is JNI, coz I heard a lot about it whenever something "native" has to be called in Java. Just while surfing for the more information on basic JNI programming, I came across the JNA project/api and find it interesting to give it try. Here are the basic two things you need to have in order to use JNA 1) JNA api JAR file (jna.jar): Download it from here 2) DLL which you want to call in your Java program Now this may be the big thing for a guy who haven't worked on VC++, DLL, MFC etc things. So here is the quick link about how to create the DLL http://www.icynorth.com/development/createdl...

How to fetch NULL data into C-ODBC program?

From last two months I’m working on C-ODBC project, despite my expertise in Java. This was I encountered while development. Problem : C-ODBC API does not provide any function which fetch NULL data without throwing a runtime error. Solution : Need to provide an indicator , which get set when row data contained NULL for that specific column. 1. Define the long typed variable for holding indication about NULL data: SQLINTEGER i_first_name, i_last_name, i_age; // i for indicator 2. Passed this indicator variable to SQLBindCol function: SQLBindCol(hstmt, 1, SQL_C_CHAR, first_name, 100, &i_first_name); SQLBindCol(hstmt, 2, SQL_C_CHAR, last_name, 100, &i_larst_name); SQLBindCol(hstmt, 3, SQL_C_CHAR, age, 100, &i_age); More Information: http://msdn.microsoft.com/en-us/library/ms711010.aspx 3. Check whether we fetched any NULL data into a column by checking, if(i_first_name == SQL_NULL_DATA) { // I put a “null” string into fist_name variable. strcpy(fi...