Re: [sqlite] Convert SQLite to Java
Steve O'Hara wrote: I have used SQLite in a whole bundle of applications and I love it. However, I've got an app that's being written in Java - I've got a JNI library (Solaris & Windows) for SQLite, but I really want something platform independent. I've been worn down by my quest for a comparable product to SQLite written in pure Java and have come to the conclusion that it doesn't exit. I've looked at Derby, QED, Axion, blah blah and I'm not too impressed by any of them. None of them are as good as SQLite and they all use multiple files for their storage. My next port of call is to look at the feasibility of converting the SQLite source into Java! I'd like to know whether a) anyone has tried this before, b) what might be the pitfalls and c) am I being completely mental in even thinking about trying this? Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg] On Behalf Of Martin Engelschalk Sent: 24 October 2005 20:32 To: sqlite-users@sqlite.org Subject: Re: [sqlite] glibc detected... Hi, As Christian said, probably your heap is corrupted. Your backtrace clearly indicates that. The typical errors that lead to this are - you free() some memory twice - you free more or less memory than you malloc() ed - you overrun a buffer on the heap valgrind is a good tool to detect such mistakes. Martin [EMAIL PROTECTED] schrieb: tanx for the advice...but how to avoid heap corruption? and why does it happen? anyway, finally here is the backtrace: *** glibc detected *** malloc(): memory corruption: 0x0808e078 *** Program received signal SIGABRT, Aborted. [Switching to Thread -1213548864 (LWP 4348)] 0xe410 in __kernel_vsyscall () (gdb) ba #0 0xe410 in __kernel_vsyscall () #1 0x4fad57d5 in raise () from /lib/tls/libc.so.6 #2 0x4fad7149 in abort () from /lib/tls/libc.so.6 #3 0x4fb0927a in __libc_message () from /lib/tls/libc.so.6 #4 0x4fb1049c in _int_malloc () from /lib/tls/libc.so.6 #5 0x4fb11f01 in malloc () from /lib/tls/libc.so.6 #6 0xb7d95c03 in sqlite3Malloc (n=-16) at ./src/util.c:296 #7 0xb7d885f2 in sqlite3ParserAlloc ( mallocProc=0xb7d95bdc ) at parse.c:1302 #8 0xb7d9382d in sqlite3RunParser (pParse=0xb550, zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", pzErrMsg=0xb54c) at ./src/tokenize.c:349 #9 0xb7d8c777 in sqlite3_prepare (db=0x808d5d0, zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", nBytes=-1, ppStmt=0xb648, pzTail=0x0) at ./src/prepare.c:440 #10 0x0804d0ef in subjId (db=0x808d5d0, id=15, subj=0xb748, test=0x0) at database.c:901 #11 0x0804e8f8 in featVect (db=0x808d5d0, recog_id=1, maxEigen=0) at database.c:1662 #12 0x0804a26a in main (argc=5, argv=0xb864) at main.c:400 (gdb) I also noticed that error occours even if the requested row id is every time the same! So the problem occours after a certain number of iterations. The code to read is something like this: sqlite3_stmt *pStmt=0; char *sql=0; int sql_error=0; asprintf(, "SELECT subjNum FROM \"images\" WHERE id==%d;" id); if ( !sqlite3_prepare(db, sql, -1, , 0) ) { if (sqlite3_step(pStmt)==SQLITE_ROW) { test = (char*) sqlite3_column_text (pStmt,0); } else { fprintf(stderr,"\nWARNING: No image associated to requested id\n"); sql_error = 1; } } else { fprintf(stderr, "\nERROR: SQL prepare error:\n\t%s\n", sqlite3_errmsg(db)); sql_error=1; } if ( sqlite3_finalize(pStmt) != SQLITE_OK ) { fprintf(stderr, "\nERROR: SQL finalization error:\n\t%s\n", sqlite3_errmsg(db)); sql_error=1; } free(sql); if (sql_error) { sqlite3_close (db); exit(1); } it is inside a function that is called iteratively from another function, incrementing the passed id num tanks __ TISCALI ADSL Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone Telecom a partire da 19,95 Euro/mese. Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI: http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/ Does blah, blah include hsqldb/hypersonicsql? 100% java + sql compliant, acid comliant and i think it stores everything in one file, can also load and run in memory. been a while since i looked at it.
Re: [sqlite] Convert SQLite to Java
>>Java libraries linked with C (via JNI) generally have to run with the exact >>same version of Java they were built with. > > Uh-oh, Sun advertises something else. Hmm... I may have been confused in the matter by having had (unrelated) problems. I would go with what Sun advertises. Randy -- [EMAIL PROTECTED] http://www.rjray.org http://www.svsm.org We will never have true civilization until we have learned to recognize the rights of others.-- Will Rogers
Re: [sqlite] Convert SQLite to Java
On Tue, Oct 25, 2005 at 10:05:31AM -0500, John Stanton wrote: > I've been worn down by my quest for a comparable product to SQLite > written in pure Java and have come to the conclusion that it doesn't > exit. I've looked at Derby, QED, Axion, blah blah and I'm not too > impressed by any of them. > None of them are as good as SQLite and they all use multiple files for > their storage. > > Sqlite is portable to pretty much anything more advanced than an abacus, > so I don't see your problem. If there were gcc for abacus it would work > on that too :-). This company has a C to Java Bytecode compiler. E.g., compile C programs to run on a Java JVM. http://www.axiomsol.com/ I have no idea how this actually works in practice, but any SQLite fan with $49 to burn and some time might want to give it a try. -- Tom Poindexter [EMAIL PROTECTED] http://www.nyx.net/~tpoindex/
Re: [sqlite] Convert SQLite to Java
Fred injects a big dose of common sense, and a principle which goes back almost a thousand years - Occam's Razor also known as K.I.S.S. How often do we see people laboring over a high level "simple" solution to a low level problem and in exasperation jump in and solve it in a very short time with a very few lines of C or Assembler? It is our experience that computer languages are just a tool, not a culture or religion. Use the lightest one which cuts deepest and fastest for the particular application. An adept programmer can handle any language and learn a new one in no time flat. I find Sqlite a particularly well thought through product. It is simple in important ways, but not so simple that it cannot handle serious applications. Like other successful systems it is "a coherent system that pushes a few good ideas to the limit". A lesson in simplicity well worth pondering. JS Fred Williams wrote: Well I kind'a hope you are not a screaming Java bigot, but there are serious reasons particular programming languages are chosen for particular projects. And if the language choice is done properly, logically, and realistically it will definitely not be the only language the programmer happens to know. Harkens back to the very old joke, "He can write Fortran in any language!" If my world was perfect we would all still be writing ASSEMBLER... But, I use the poor substitute "C" when performance, module size, and portability are important. When I feel real lazy or the client starts screaming about the overtime, I use a "third generation" language (Object Oriented.) If I particularly dislike the client and want to get rid of him as fast as I can, I use an interpreted language (no compile time). And as I slip away he is on the phone ordering bigger and faster hardware. Fred
Re: [sqlite] Convert SQLite to Java
On 10/25/05, Clay Dowling <[EMAIL PROTECTED]> wrote: > No matter if JVM versions do or don't have to be matched, using a native > DLL is clearly not a good solution for the original poster. It does > completely defeat the compile once run anywhere goal of Java. Presumably > if he was willing to accept platform lock-in he would just write the app > in C++ and be done with it. If he knew C++, and I've found C++ to be as portable as anything else I've tried. It's not the language that makes things unportable, it's the environment.
Re: [sqlite] Convert SQLite to Java
I've been worn down by my quest for a comparable product to SQLite written in pure Java and have come to the conclusion that it doesn't exit. I've looked at Derby, QED, Axion, blah blah and I'm not too impressed by any of them. None of them are as good as SQLite and they all use multiple files for their storage. Sqlite is portable to pretty much anything more advanced than an abacus, so I don't see your problem. If there were gcc for abacus it would work on that too :-).
Re: [sqlite] Convert SQLite to Java
* Randy Ray: > Java libraries linked with C (via JNI) generally have to run with the exact > same version of Java they were built with. Uh-oh, Sun advertises something else. I can understand that you must exactly match JVM versions for certified configurations, but this isn't true even if you don't use native code.
Re: [sqlite] Convert SQLite to Java
Steve O'Hara wrote: The attraction of a pure Java solution is obvious - if a client wants this app to run on VMS then I've got to create another JNI library that is VMS specific. Id you've ever written any JNI you'll know why this isn't an all together pleasurable experience. Also - and this is *very* relevant for some platforms, sometimes you don't have access to C or DLL/libs on a platform. I work on MEAP (embedded java on Canon printers) and we have to get our Java source OK'd by canon before we are given a key to for installing it on general canon hardware. No chance at all that we'd be allowed to upload DLL's or compile C on the platform. -- Lindsay
Re: [sqlite] Convert SQLite to Java
[EMAIL PROTECTED] wrote: hsql is pretty smart in java, the storage is editable by texpad it is only consisted of sql statements. It s an in memory only DB It can store and use on disk db as well. I was evaluating it for an embedded DB, seemed prety easy to use. I haven't used it in anger yet though. -- Lindsay
RE: [sqlite] Convert SQLite to Java
As I mentioned in my question, I have already written a JNI library for Windows and Solaris for SQLite they work fine. And no Jay, you can't "link" DLLs/Shared Libraries into Java, you can bind to them via a JNI container. The attraction of a pure Java solution is obvious - if a client wants this app to run on VMS then I've got to create another JNI library that is VMS specific. Id you've ever written any JNI you'll know why this isn't an all together pleasurable experience. I've tried the C2J application and that actually looks like it does a reasonbale job but with a whole load of missing stuff, mainly in pager.c I'll have another crack at it when I get a bit more time. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg] On Behalf Of Andrew Piskorski Sent: 24 October 2005 22:21 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Convert SQLite to Java On Mon, Oct 24, 2005 at 09:58:53PM +0100, Steve O'Hara wrote: > I've been worn down by my quest for a comparable product to SQLite > written in pure Java and have come to the conclusion that it doesn't > exit. I've looked at Derby, QED, Axion, blah blah and I'm not too > My next port of call is to look at the feasibility of converting the > SQLite source into Java! Uh, why isn't your first choice simply, "Use SQLite from Java"? Surely calling C libraries is something the Java folks have worked out how to do many years ago? Or what am I missing here? What is the attraction of "pure Java"? -- Andrew Piskorski <[EMAIL PROTECTED]> http://www.piskorski.com/
Re: [sqlite] Convert SQLite to Java
> Uh, why isn't your first choice simply, "Use SQLite from Java"? > Surely calling C libraries is something the Java folks have worked out > how to do many years ago? Or what am I missing here? What is the > attraction of "pure Java"? Java libraries linked with C (via JNI) generally have to run with the exact same version of Java they were built with. That is, something linked against 1.4.2_03 isn't likely to run on 1.4.2_06. That, and the Java bindings don't have as much active support and development as other languages do. Randy -- [EMAIL PROTECTED] http://www.rjray.org http://www.svsm.org We will never have true civilization until we have learned to recognize the rights of others.-- Will Rogers
Re: [sqlite] Convert SQLite to Java
On Mon, Oct 24, 2005 at 09:58:53PM +0100, Steve O'Hara wrote: > I've been worn down by my quest for a comparable product to SQLite > written in pure Java and have come to the conclusion that it doesn't > exit. I've looked at Derby, QED, Axion, blah blah and I'm not too > My next port of call is to look at the feasibility of converting the > SQLite source into Java! Uh, why isn't your first choice simply, "Use SQLite from Java"? Surely calling C libraries is something the Java folks have worked out how to do many years ago? Or what am I missing here? What is the attraction of "pure Java"? -- Andrew Piskorski <[EMAIL PROTECTED]> http://www.piskorski.com/
Re: [sqlite] Convert SQLite to Java
On 10/24/05, Steve O'Hara <[EMAIL PROTECTED]> wrote: > I've been worn down by my quest for a comparable product to SQLite > written in pure Java and have come to the conclusion that it doesn't > exit. I've looked at Derby, QED, Axion, blah blah and I'm not too > impressed by any of them. > None of them are as good as SQLite and they all use multiple files for > their storage. You can't link DLL's into java? Why reinvent it if you can just use the original?
Re: [sqlite] Convert SQLite to Java
hsql is pretty smart in java, the storage is editable by texpad it is only consisted of sql statements. It s an in memory only DB Benjamin Filippi Capital Fund Management 6 boulevard Haussmann 75009 Paris Tel: +33 1 49 49 59 30 Fax: +33 1 47 70 17 40 [EMAIL PROTECTED] http://www.cfm.fr "Steve O'Hara" <[EMAIL PROTECTED]> 10/24/2005 10:58 PM Please respond to sqlite-users To: <sqlite-users@sqlite.org> cc: Subject: [sqlite] Convert SQLite to Java I have used SQLite in a whole bundle of applications and I love it. However, I've got an app that's being written in Java - I've got a JNI library (Solaris & Windows) for SQLite, but I really want something platform independent. I've been worn down by my quest for a comparable product to SQLite written in pure Java and have come to the conclusion that it doesn't exit. I've looked at Derby, QED, Axion, blah blah and I'm not too impressed by any of them. None of them are as good as SQLite and they all use multiple files for their storage. My next port of call is to look at the feasibility of converting the SQLite source into Java! I'd like to know whether a) anyone has tried this before, b) what might be the pitfalls and c) am I being completely mental in even thinking about trying this? Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg] On Behalf Of Martin Engelschalk Sent: 24 October 2005 20:32 To: sqlite-users@sqlite.org Subject: Re: [sqlite] glibc detected... Hi, As Christian said, probably your heap is corrupted. Your backtrace clearly indicates that. The typical errors that lead to this are - you free() some memory twice - you free more or less memory than you malloc() ed - you overrun a buffer on the heap valgrind is a good tool to detect such mistakes. Martin [EMAIL PROTECTED] schrieb: >tanx for the advice...but how to avoid heap corruption? and why does it happen? >anyway, finally here is the backtrace: > >*** glibc detected *** malloc(): memory corruption: 0x0808e078 *** > >Program received signal SIGABRT, Aborted. >[Switching to Thread -1213548864 (LWP 4348)] >0xe410 in __kernel_vsyscall () >(gdb) ba >#0 0xe410 in __kernel_vsyscall () >#1 0x4fad57d5 in raise () from /lib/tls/libc.so.6 >#2 0x4fad7149 in abort () from /lib/tls/libc.so.6 >#3 0x4fb0927a in __libc_message () from /lib/tls/libc.so.6 >#4 0x4fb1049c in _int_malloc () from /lib/tls/libc.so.6 >#5 0x4fb11f01 in malloc () from /lib/tls/libc.so.6 >#6 0xb7d95c03 in sqlite3Malloc (n=-16) at ./src/util.c:296 >#7 0xb7d885f2 in sqlite3ParserAlloc ( >mallocProc=0xb7d95bdc ) at parse.c:1302 >#8 0xb7d9382d in sqlite3RunParser (pParse=0xb550, >zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", >pzErrMsg=0xb54c) at ./src/tokenize.c:349 >#9 0xb7d8c777 in sqlite3_prepare (db=0x808d5d0, >zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", >nBytes=-1, ppStmt=0xb648, pzTail=0x0) at ./src/prepare.c:440 >#10 0x0804d0ef in subjId (db=0x808d5d0, id=15, subj=0xb748, >test=0x0) at database.c:901 >#11 0x0804e8f8 in featVect (db=0x808d5d0, recog_id=1, maxEigen=0) >at database.c:1662 >#12 0x0804a26a in main (argc=5, argv=0xb864) at main.c:400 >(gdb) > >I also noticed that error occours even if the requested row id is every time >the same! >So the problem occours after a certain number of iterations. >The code to read is something like this: > >sqlite3_stmt *pStmt=0; >char *sql=0; >int sql_error=0; > >asprintf(, "SELECT subjNum FROM \"images\" WHERE id==%d;" id); >if ( !sqlite3_prepare(db, sql, -1, , 0) ) >{ >if (sqlite3_step(pStmt)==SQLITE_ROW) >{ >test = (char*) sqlite3_column_text (pStmt,0); >} >else >{ > fprintf(stderr,"\nWARNING: No image associated to requested id\n"); >sql_error = 1; >} >} >else >{ >fprintf(stderr, "\nERROR: SQL prepare error:\n\t%s\n", sqlite3_errmsg(db)); >sql_error=1; >} > >if ( sqlite3_finalize(pStmt) != SQLITE_OK ) >{ >fprintf(stderr, "\nERROR: SQL finalization error:\n\t%s\n", sqlite3_errmsg(db)); >sql_error=1; >
[sqlite] Convert SQLite to Java
I have used SQLite in a whole bundle of applications and I love it. However, I've got an app that's being written in Java - I've got a JNI library (Solaris & Windows) for SQLite, but I really want something platform independent. I've been worn down by my quest for a comparable product to SQLite written in pure Java and have come to the conclusion that it doesn't exit. I've looked at Derby, QED, Axion, blah blah and I'm not too impressed by any of them. None of them are as good as SQLite and they all use multiple files for their storage. My next port of call is to look at the feasibility of converting the SQLite source into Java! I'd like to know whether a) anyone has tried this before, b) what might be the pitfalls and c) am I being completely mental in even thinking about trying this? Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg] On Behalf Of Martin Engelschalk Sent: 24 October 2005 20:32 To: sqlite-users@sqlite.org Subject: Re: [sqlite] glibc detected... Hi, As Christian said, probably your heap is corrupted. Your backtrace clearly indicates that. The typical errors that lead to this are - you free() some memory twice - you free more or less memory than you malloc() ed - you overrun a buffer on the heap valgrind is a good tool to detect such mistakes. Martin [EMAIL PROTECTED] schrieb: >tanx for the advice...but how to avoid heap corruption? and why does it happen? >anyway, finally here is the backtrace: > >*** glibc detected *** malloc(): memory corruption: 0x0808e078 *** > >Program received signal SIGABRT, Aborted. >[Switching to Thread -1213548864 (LWP 4348)] >0xe410 in __kernel_vsyscall () >(gdb) ba >#0 0xe410 in __kernel_vsyscall () >#1 0x4fad57d5 in raise () from /lib/tls/libc.so.6 >#2 0x4fad7149 in abort () from /lib/tls/libc.so.6 >#3 0x4fb0927a in __libc_message () from /lib/tls/libc.so.6 >#4 0x4fb1049c in _int_malloc () from /lib/tls/libc.so.6 >#5 0x4fb11f01 in malloc () from /lib/tls/libc.so.6 >#6 0xb7d95c03 in sqlite3Malloc (n=-16) at ./src/util.c:296 >#7 0xb7d885f2 in sqlite3ParserAlloc ( >mallocProc=0xb7d95bdc ) at parse.c:1302 >#8 0xb7d9382d in sqlite3RunParser (pParse=0xb550, >zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", >pzErrMsg=0xb54c) at ./src/tokenize.c:349 >#9 0xb7d8c777 in sqlite3_prepare (db=0x808d5d0, >zSql=0x8093c38 "SELECT subjNum FROM \"images\" WHERE id==15;", >nBytes=-1, ppStmt=0xb648, pzTail=0x0) at ./src/prepare.c:440 >#10 0x0804d0ef in subjId (db=0x808d5d0, id=15, subj=0xb748, >test=0x0) at database.c:901 >#11 0x0804e8f8 in featVect (db=0x808d5d0, recog_id=1, maxEigen=0) >at database.c:1662 >#12 0x0804a26a in main (argc=5, argv=0xb864) at main.c:400 >(gdb) > >I also noticed that error occours even if the requested row id is every time >the same! >So the problem occours after a certain number of iterations. >The code to read is something like this: > >sqlite3_stmt *pStmt=0; > char *sql=0; > int sql_error=0; > > asprintf(, "SELECT subjNum FROM \"images\" WHERE id==%d;" id); > if ( !sqlite3_prepare(db, sql, -1, , 0) ) > { > if (sqlite3_step(pStmt)==SQLITE_ROW) > { > test = (char*) sqlite3_column_text (pStmt,0); > } > else > { > fprintf(stderr,"\nWARNING: No image associated to requested id\n"); > sql_error = 1; > } > } > else > { > fprintf(stderr, "\nERROR: SQL prepare error:\n\t%s\n", sqlite3_errmsg(db)); > sql_error=1; > } > > if ( sqlite3_finalize(pStmt) != SQLITE_OK ) > { > fprintf(stderr, "\nERROR: SQL finalization error:\n\t%s\n", sqlite3_errmsg(db)); > sql_error=1; > } > > free(sql); > > if (sql_error) > { > sqlite3_close (db); > exit(1); > } > >it is inside a function that is called iteratively from another function, >incrementing the passed id num >tanks > >__ >TISCALI ADSL >Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone >Telecom a partire da 19,95 Euro/mese. >Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI: >http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/ > > > > >