Re: JDBC problem!
ALPESH KOTHARI wrote: > > Hello Everybody, [snip] > following exception: > java.sql.SQLException: ERROR: parser: parse error at > or near "" > [snip] > try > { > pid1=din.readInt(); > System.out.println(pid1); > int len1=din.readByte(); > byte[] lent=new byte[len1+2]; > for(int i=0;i<=len1+1;i++) > { > lent[i]=din.readByte(); > } > test1=new String(lent); > System.out.println(test1); > ps.setInt(1,pid1); > ps.setString(2,test1); > try{ > int x=ps.executeUpdate(); > } > catch (SQLException ex){ > System.out.println("Exception="+ex); > } > I would expect that you are needing single quotation marks around the string built for the char() field in the database, so that the insert would have 'foo' as a parameter rather than just foo. You can also direct the question to the postgresql interfaces mailing list, where Peter Mount is very helpful with problems regarding his excellent JDBC driver. Dallas Hockley [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: JDBC problem!
Try converting the int into a string. E.g. >int pid1; > pid1=din.readInt(); String pid1; pid1 = Integer.toString(din.readInt()); I didn't test it, but this seems like the problem. Troy > > Hello Everybody, > > I have written one program in java2 to write the data > in postgresql. I am storing one integer and one string > in the database. When i read the string from the file > it is proper. But when i store it, it gives the > following exception: > java.sql.SQLException: ERROR: parser: parse error at > or near "" > > I am not able to detect the error. Can any one run the > code and correct the problem? > When I assign the string test1 some fixed value and > store it then the program works fine. > > Here is the code: > > > //Import Various Classes > import javax.swing.*; > import javax.swing.border.*; > import java.awt.*; > import java.awt.event.*; > import java.io.*; > import java.util.*; > import java.sql.*; > import java.text.*; > > // THE CLASS DEFINITATION OF MAIN FRAME. > class db1 > { > > Connection db; > Statement st; > //THIS IS THE MAIN METHOD > public db1(String args[]) throws > ClassNotFoundException,FileNotFoundException,IOException,SQLException > { >String url = args[0]; >String usr = args[1]; >String pwd = args[2]; > >int pid1; >String test1=null; >Class.forName("postgresql.Driver"); > >// Connect to database > System.out.println("Connecting to Database URL = " + > url); > db = DriverManager.getConnection(url, usr, pwd); > > System.out.println("Connected...Now creating a > statement"); > st = db.createStatement(); > st.executeUpdate("create table temp125(pid > int4,filen char(200))"); > > PreparedStatement ps = db.prepareStatement("insert > into temp125 values (?,?)"); > try > { > FileInputStream fin=new FileInputStream("test1"); > DataInputStream din=new DataInputStream(fin); > try > { > pid1=din.readInt(); > System.out.println(pid1); > int len1=din.readByte(); > byte[] lent=new byte[len1+2]; > for(int i=0;i<=len1+1;i++) > { > lent[i]=din.readByte(); > } > test1=new String(lent); > System.out.println(test1); > ps.setInt(1,pid1); > ps.setString(2,test1); > try{ > int x=ps.executeUpdate(); > } > catch (SQLException ex){ > System.out.println("Exception="+ex); > } > > > > } > catch(IOException e1) > { > System.out.println("IO"); > } > > } > catch(FileNotFoundException e) > { > System.out.println("File not found"); > } > ps.close(); > > > System.out.println("Now closing the connection"); > st.close(); > db.close(); > > } > > public static void main(String[] args) > { > try { > db1 temp = new db1(args); > } catch(Exception ex) { > System.err.println("Exception caught.\n"+ex); > ex.printStackTrace(); > } > } > } > > * > The file which i read is test1 which is something > like: > > wyt7GIsstustututuC4?? > > Please run the code on your computer and let me know > the problem. > > Thanking You > > > = > KOTHARI ALPESH D. > STUDENT M. TECH. > CEDT > INDIAN INSTITUTE OF SCIENCE > BANGALORE-560 012 > INDIA > __ > Do You Yahoo!? > Bid and sell for free at http://auctions.yahoo.com > > > ---
javah doesn't DTRT
I'm finding that Blackdown javah version 1.2 is generating C prototypes that are missing the package name. In particular, I have the following in "FitNative.java": package fit; public class FitNative { static native String realName(String username) throws NoSuchUserException; static native String homeDirectory(String username) throws NoSuchUserException; static native boolean checkPassword(String username, String password); static { System.loadLibrary("FitNative"); } } I compile the file: "javac FitNative.java". Then I create the .h file: "javah -jni FitNative". Then, when I look in "FitNative.h", I see the following prototypes: JNIEXPORT jboolean JNICALL Java_fit_FitNative_checkPassword (JNIEnv *, jclass, jstring, jstring); JNIEXPORT jstring JNICALL Java_fit_FitNative_homeDirectory (JNIEnv *, jclass, jstring); JNIEXPORT jstring JNICALL Java_fit_FitNative_realName (JNIEnv *, jclass, jstring); If I use those names for my C functions, then at runtime I get a java.lang.UnsatisfiedLinkError when I try to call one of the native methods. Instead, I have to edit the "FitNative.h" file so that the functions include the package name: Java_fit_FitNative_checkPassword, Java_fit_FitNative_homeDirectory, and Java_fit_FitNative_realName. Is javah behaving incorrectly or am I invoking it wrong? Solomon -- Solomon <|> [EMAIL PROTECTED] Douglas /|\ http://web.mit.edu/srcd/www/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: javah doesn't DTRT
> Try 'javah -jni fit.FitNative' and it will work. By Jove, you're right... In fact, I had tried that before but I hadn't noticed that the resulting filename was "fit_FitNative.h", so I was still looking at the previous FitNative.h that I had generated. Thanks, Solomon -- Solomon <|> [EMAIL PROTECTED] Douglas /|\ http://web.mit.edu/srcd/www/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: javah doesn't DTRT
> Solomon Douglas writes: Solomon> I'm finding that Blackdown javah version 1.2 is generating C Solomon> prototypes that are missing the package name. This not Linux specific; the problem is that you don't use the fully qualified class name: Solomon>package fit; Solomon>public class FitNative [...] Solomon> I compile the file: "javac FitNative.java". Solomon> Then I create the .h file: "javah -jni FitNative". Try 'javah -jni fit.FitNative' and it will work. Juergen -- Juergen Kreileder, Blackdown Java-Linux Porting Team http://www.blackdown.org/java-linux.html -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: NoClassDefFoundError and RH6.0
At 09:04 9/29/99 -0500, Roll, Greg wrote: >Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class you didn't by any chance type "java HelloWorld.class" did you? cabbey at home dot net <*> http://members.home.net/cabbey I want a binary interface to the brain! Today's opto-mechanical digital interfaces are just too slow! -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
JMenu Rendering Errors
I am have a strange problem. Menu's in my application are rendering with a gap between the menubar and the acutal menu. The gap is just blank space which you can click through and is about the height of one JMenuItem. I made no changes to any of my menu's or menubars. In fact it just appeared suddenly. I haven't made any major changes. It also happens on JPopupMenus. Has anyone else expierenced this problem? Thanks. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Java and Enlightenment
The authors of the Enlightenment window manager have some interesting comments today about Java: http://www.enlightenment.org/news.html Their basic point is that "Java under X (AWT) is Broken"; they don't mention which Java implementation they're referring to. I don't think things are all that bad with either version of the Blackdown port (or with the new IBM 1.1.8 implementation either, for that matter), but I have noticed that dialogs (in particular) tend to drift a bit under various window managers, even though there's explicit code in the application to save and restore their position. Both Enlightenment and Windowmaker seem to have this problem, but icewm, last time I checked, did not. Windows VMs don't seem to have this problem at all. -Peter http://armedbear.org -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Java and Enlightenment
Peter Graves wrote: > The authors of the Enlightenment window manager have some > interesting comments today about Java: > > http://www.enlightenment.org/news.html > > Their basic point is that "Java under X (AWT) is Broken"; they > don't mention which Java implementation they're referring to. > > I don't think things are all that bad with either version of the > Blackdown port (or with the new IBM 1.1.8 implementation either, > for that matter), but I have noticed that dialogs (in particular) > tend to drift a bit under various window managers, even though > there's explicit code in the application to save and restore > their position. Both Enlightenment and Windowmaker seem to have > this problem, but icewm, last time I checked, did not. Windows > VMs don't seem to have this problem at all. > Actually java works well under KDE some bugs under Windowmaker major bugs under Enlightenment . Gnome seems to break stuff too. I wont except bug reports for linux unless there verified under KDE. Also java works under all the other Unixes Sun/SGI/HP that I've tested. I'd say its Enlightenment plus Gnome does not help. If your the only badly busted platfrom it aint X. Mike -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Java and Enlightenment
Peter Graves wrote: > > The authors of the Enlightenment window manager have some > interesting comments today about Java: > > http://www.enlightenment.org/news.html > > Their basic point is that "Java under X (AWT) is Broken"; they > don't mention which Java implementation they're referring to. Haven't seen this on Linux, but JDK 1.1.6 on Solaris has major problems with placement of newly created Frames. The E team's allegation that AWT is not following the rules is believable. As AWT has to work with Sun's OpenWin (Motif 1.2) and Sun's X server for Windows NT, which is a little bit different from the major brands like Exceed, there is not a whole lot that it can do to make informed decisions. I do remember reading comments in the AWT source files which states that AWT don't even know if the window bounds that it has gotten back from the X server includes the decorations or not. > I don't think things are all that bad with either version of the > Blackdown port (or with the new IBM 1.1.8 implementation either, > for that matter), but I have noticed that dialogs (in particular) > tend to drift a bit under various window managers, even though > there's explicit code in the application to save and restore > their position. Both Enlightenment and Windowmaker seem to have > this problem, but icewm, last time I checked, did not. Windows > VMs don't seem to have this problem at all. -- Weiqi Gao [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]