SQLite + JDBC + Jython. Example

View: New views
11 Messages — Rating Filter:   Alert me  

SQLite + JDBC + Jython. Example

by Alfonso Reyes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The following is another basic example that illustrates the use of a SQLite driver for Java. Python already enjoys of a package for SQLite called pysqlite but unfortunately is not callable from Jython. I am attaching the SQLite database alpha.db that is part of the example.

References:
sqliteJDBC: http://www.zentus.com/sqlitejdbc/
Tutorial: http://www.pysquared.com/files/Java/JavaSQLiteExample/

Add to classpath or /jre/lib/ext:
sqlitejdbc-v037-nested.jar

Sample Code: from java.sql import DriverManager from java.sql import SQLException from java.lang import Class import sys class SQLiteDB: def __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC" self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def open(self): try: self.db = DriverManager.getConnection(self.url); stat1 = self.db.createStatement() print self.db except SQLException, e: print e.message print "cannot create connection with current driver" print "revise url and try again. Will exit application ..." sys.exit() def view(self): try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); # Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id, "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e: print e.message print "cannot open table" def close(self): self.db.close(); if __name__ == '__main__': app = SQLiteDB() app.open() app.view() app.close() alpha.db

Cheers!
Alfonso Reyes

Re: SQLite + JDBC + Jython. Example

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alfonso,

It appears whatever Nabble is doing to format these when you're
posting them is lost when they're sent on to the mailing list.  The
code is a single block for me instead of multiple correctly indented
lines, and I imagine most people are seeing the same thing.  It'd
probably be better to add things like these to the examples section on
http://wiki.python.org/jython/DocumentationAndEducation anyway since
they can be kept up to date or improved there.

Charlie

On 10/20/07, Alfonso Reyes <msfz751@...> wrote:

>  The following is another basic example that illustrates the use of a SQLite
> driver for Java. Python already enjoys of a package for SQLite called
> pysqlite but unfortunately is not callable from Jython. I am attaching the
> SQLite database alpha.db that is part of the example.
>
>  References:
>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
>  Tutorial:
> http://www.pysquared.com/files/Java/JavaSQLiteExample/
>
>  Add to classpath or /jre/lib/ext:
>  sqlitejdbc-v037-nested.jar
>
>  Sample Code: from java.sql import DriverManager from java.sql import
> SQLException from java.lang import Class import sys class SQLiteDB: def
> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> self.db.createStatement() print self.db except SQLException, e: print
> e.message print "cannot create connection with current driver" print "revise
> url and try again. Will exit application ..." sys.exit() def view(self):
> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM
> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column
> 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); #
> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e:
> print e.message print "cannot open table" def close(self): self.db.close();
> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> app.close() alpha.db
>
>  Cheers!
>  Alfonso Reyes
> ________________________________
>  View this message in context: SQLite + JDBC + Jython. Example
>  Sent from the jython-users mailing list archive at Nabble.com.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Brent Pedersen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi, i have the same prob with formatting through gmail, but with "view
original", it is possible to see the format intended (== indented).
even if they appear on the wiki, i for one would like to see them on
the mailing list as well. they've been very helpful for me.
-brent


On 10/20/07, Charlie Groves <charlie.groves@...> wrote:

> Hi Alfonso,
>
> It appears whatever Nabble is doing to format these when you're
> posting them is lost when they're sent on to the mailing list.  The
> code is a single block for me instead of multiple correctly indented
> lines, and I imagine most people are seeing the same thing.  It'd
> probably be better to add things like these to the examples section on
> http://wiki.python.org/jython/DocumentationAndEducation anyway since
> they can be kept up to date or improved there.
>
> Charlie
>
> On 10/20/07, Alfonso Reyes <msfz751@...> wrote:
> >  The following is another basic example that illustrates the use of a SQLite
> > driver for Java. Python already enjoys of a package for SQLite called
> > pysqlite but unfortunately is not callable from Jython. I am attaching the
> > SQLite database alpha.db that is part of the example.
> >
> >  References:
> >  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
> >  Tutorial:
> > http://www.pysquared.com/files/Java/JavaSQLiteExample/
> >
> >  Add to classpath or /jre/lib/ext:
> >  sqlitejdbc-v037-nested.jar
> >
> >  Sample Code: from java.sql import DriverManager from java.sql import
> > SQLException from java.lang import Class import sys class SQLiteDB: def
> > __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> > self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> > open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> > self.db.createStatement() print self.db except SQLException, e: print
> > e.message print "cannot create connection with current driver" print "revise
> > url and try again. Will exit application ..." sys.exit() def view(self):
> > try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM
> > letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column
> > 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); #
> > Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> > "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e:
> > print e.message print "cannot open table" def close(self): self.db.close();
> > if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> > app.close() alpha.db
> >
> >  Cheers!
> >  Alfonso Reyes
> > ________________________________
> >  View this message in context: SQLite + JDBC + Jython. Example
> >  Sent from the jython-users mailing list archive at Nabble.com.
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems?  Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@...
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >
> >
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Alfonso Reyes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the heads-up.
I will try to format the code in a different way.
By the way, is there a recommended practice to insert code at this forum?.
Thanks.

Alfonso Reyes wrote:
The following is another basic example that illustrates the use of a SQLite driver for Java. Python already enjoys of a package for SQLite called pysqlite but unfortunately is not callable from Jython. I am attaching the SQLite database alpha.db that is part of the example.<br><br>

References:<br>
sqliteJDBC: http://www.zentus.com/sqlitejdbc/<br>
Tutorial: http://www.pysquared.com/files/Java/JavaSQLiteExample/
<br><br>
Add to classpath or /jre/lib/ext:<br>
sqlitejdbc-v037-nested.jar
<br><br>

Sample Code:
<xmp>
from java.sql import DriverManager
from java.sql import SQLException
from java.lang import Class
import sys

class SQLiteDB:
    def __init__(self):
        self.database = "alpha.db"
        driver = "org.sqlite.JDBC"        
        self.url = "jdbc:sqlite:" + self.database
        Class.forName(driver);

    def open(self):
        try:
            self.db = DriverManager.getConnection(self.url);
            stat1 = self.db.createStatement()
            print self.db
        except SQLException, e:
            print e.message
            print "cannot create connection with current driver"
            print "revise url and try again. Will exit application ..."
            sys.exit()

    def view(self):
        try:
            stmt = self.db.createStatement();
            rs = stmt.executeQuery("SELECT * FROM letters ORDER BY ID");

            while (rs.next()):
                id     = rs.getString("ID");       # Column 1
                letter = rs.getString("letter");   # Column 2
                name   = rs.getString("name");     # Column 3
                cat    = rs.getString("categoryID"); # Column 4
                print "ID:", id, "Code:", letter, "Name:", name, "\tCategory:", cat
        except SQLException, e:
            print e.message
            print "cannot open table"

    def close(self):
        self.db.close();

if __name__ == '__main__':
    app = SQLiteDB()
    app.open()
    app.view()
    app.close()
</xmp>alpha.db
<br><br>
Cheers!
<br>
Alfonso Reyes

Re: SQLite + JDBC + Jython. Example

by Byron-18 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alfonso Reyes wrote:
> Thanks for the heads-up. I will try to format the code in a
> different way. By the way, is there a recommended practice to
> insert code at this forum?. Thanks.

Your post is going out as both text and html (message contains a copy
in each format), The people who can't read your post are using readers
that are showing your post in html, which without <pre> blocks is
going to look like a mess.  Try and send it in text only.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Ivan Horvath-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Alfonso,

i have some strange results when i tried to use msde with Jython. i
posted some mail to the list, but there were no any answer. the
subject of the mail: another jdbc related question

it is about to get the databases from msde using zxJdbc, and orig.
jdbc. i received different result.

do you have any experience using other databases with Jython?

thanks
Ivan

On 10/20/07, Alfonso Reyes <msfz751@...> wrote:

>  The following is another basic example that illustrates the use of a SQLite
> driver for Java. Python already enjoys of a package for SQLite called
> pysqlite but unfortunately is not callable from Jython. I am attaching the
> SQLite database alpha.db that is part of the example.
>
>  References:
>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
>  Tutorial:
> http://www.pysquared.com/files/Java/JavaSQLiteExample/
>
>  Add to classpath or /jre/lib/ext:
>  sqlitejdbc-v037-nested.jar
>
>  Sample Code: from java.sql import DriverManager from java.sql import
> SQLException from java.lang import Class import sys class SQLiteDB: def
> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> self.db.createStatement() print self.db except SQLException, e: print
> e.message print "cannot create connection with current driver" print "revise
> url and try again. Will exit application ..." sys.exit() def view(self):
> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM
> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column
> 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); #
> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e:
> print e.message print "cannot open table" def close(self): self.db.close();
> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> app.close() alpha.db
>
>  Cheers!
>  Alfonso Reyes
> ________________________________
>  View this message in context: SQLite + JDBC + Jython. Example
>  Sent from the jython-users mailing list archive at Nabble.com.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>


--
"De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
ments meg Uram minket!"

http://www.freeweb.hu/pillesoft

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Michael Chisholm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fyi, the emails are coming through fine for me; I am using Thunderbird
2.0.0.6.  I believe Thunderbird is showing the HTML version.  The code
block appears to be surrounded by <xmp> tags, which are deprecated, so
that's the likely problem.  Whatever's composing the HTML is using
outdated tags.

Andy

Charlie Groves wrote:

> Hi Alfonso,
>
> It appears whatever Nabble is doing to format these when you're
> posting them is lost when they're sent on to the mailing list.  The
> code is a single block for me instead of multiple correctly indented
> lines, and I imagine most people are seeing the same thing.  It'd
> probably be better to add things like these to the examples section on
> http://wiki.python.org/jython/DocumentationAndEducation anyway since
> they can be kept up to date or improved there.
>
> Charlie
>
> On 10/20/07, Alfonso Reyes <msfz751@...> wrote:
>  
>>  The following is another basic example that illustrates the use of a SQLite
>> driver for Java. Python already enjoys of a package for SQLite called
>> pysqlite but unfortunately is not callable from Jython. I am attaching the
>> SQLite database alpha.db that is part of the example.
>>
>>  References:
>>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
>>  Tutorial:
>> http://www.pysquared.com/files/Java/JavaSQLiteExample/
>>
>>  Add to classpath or /jre/lib/ext:
>>  sqlitejdbc-v037-nested.jar
>>
>>  Sample Code: from java.sql import DriverManager from java.sql import
>> SQLException from java.lang import Class import sys class SQLiteDB: def
>> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
>> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
>> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
>> self.db.createStatement() print self.db except SQLException, e: print
>> e.message print "cannot create connection with current driver" print "revise
>> url and try again. Will exit application ..." sys.exit() def view(self):
>> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM
>> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column
>> 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); #
>> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
>> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e:
>> print e.message print "cannot open table" def close(self): self.db.close();
>> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
>> app.close() alpha.db
>>
>>  Cheers!
>>  Alfonso Reyes
>> ________________________________
>>  View this message in context: SQLite + JDBC + Jython. Example
>>  Sent from the jython-users mailing list archive at Nabble.com.
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users@...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
>>    
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>  



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Alfonso Reyes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ivan
I don't have experience with msde but I may be able to help you.
What is the driver that you use with msde? Could you send me a sample code and a link to download the driver jdbc.msde?

Thanks,
Alfonso


Ivan Horvath-3 wrote:
Dear Alfonso,

i have some strange results when i tried to use msde with Jython. i
posted some mail to the list, but there were no any answer. the
subject of the mail: another jdbc related question

it is about to get the databases from msde using zxJdbc, and orig.
jdbc. i received different result.

do you have any experience using other databases with Jython?

thanks
Ivan

On 10/20/07, Alfonso Reyes <msfz751@reyesaguayo.com> wrote:
>  The following is another basic example that illustrates the use of a SQLite
> driver for Java. Python already enjoys of a package for SQLite called
> pysqlite but unfortunately is not callable from Jython. I am attaching the
> SQLite database alpha.db that is part of the example.
>
>  References:
>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
>  Tutorial:
> http://www.pysquared.com/files/Java/JavaSQLiteExample/
>
>  Add to classpath or /jre/lib/ext:
>  sqlitejdbc-v037-nested.jar
>
>  Sample Code: from java.sql import DriverManager from java.sql import
> SQLException from java.lang import Class import sys class SQLiteDB: def
> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> self.db.createStatement() print self.db except SQLException, e: print
> e.message print "cannot create connection with current driver" print "revise
> url and try again. Will exit application ..." sys.exit() def view(self):
> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT * FROM
> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); # Column
> 1 letter = rs.getString("letter"); # Column 2 name = rs.getString("name"); #
> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException, e:
> print e.message print "cannot open table" def close(self): self.db.close();
> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> app.close() alpha.db
>
>  Cheers!
>  Alfonso Reyes
> ________________________________
>  View this message in context: SQLite + JDBC + Jython. Example
>  Sent from the jython-users mailing list archive at Nabble.com.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>


--
"De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
ments meg Uram minket!"

http://www.freeweb.hu/pillesoft

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Ivan Horvath-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Alfonso,

you can find the sample codes in a mail in this mail list. its subject
is: another jdbc related question
the driver is com.microsoft.jdbc.sqlserver.SQLServerDriver
and here is the link for the setup.exe
http://download.microsoft.com/download/4/1/d/41d3e9c0-64d1-451e-947b-7a4cba273b2d/setup.exe


On 10/23/07, Alfonso Reyes <msfz751@...> wrote:

>
> Hi Ivan
> I don't have experience with msde but I may be able to help you.
> What is the driver that you use with msde? Could you send me a sample code
> and a link to download the driver jdbc.msde?
>
> Thanks,
> Alfonso
>
>
>
> Ivan Horvath-3 wrote:
> >
> > Dear Alfonso,
> >
> > i have some strange results when i tried to use msde with Jython. i
> > posted some mail to the list, but there were no any answer. the
> > subject of the mail: another jdbc related question
> >
> > it is about to get the databases from msde using zxJdbc, and orig.
> > jdbc. i received different result.
> >
> > do you have any experience using other databases with Jython?
> >
> > thanks
> > Ivan
> >
> > On 10/20/07, Alfonso Reyes <msfz751@...> wrote:
> >>  The following is another basic example that illustrates the use of a
> >> SQLite
> >> driver for Java. Python already enjoys of a package for SQLite called
> >> pysqlite but unfortunately is not callable from Jython. I am attaching
> >> the
> >> SQLite database alpha.db that is part of the example.
> >>
> >>  References:
> >>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
> >>  Tutorial:
> >> http://www.pysquared.com/files/Java/JavaSQLiteExample/
> >>
> >>  Add to classpath or /jre/lib/ext:
> >>  sqlitejdbc-v037-nested.jar
> >>
> >>  Sample Code: from java.sql import DriverManager from java.sql import
> >> SQLException from java.lang import Class import sys class SQLiteDB: def
> >> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> >> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> >> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> >> self.db.createStatement() print self.db except SQLException, e: print
> >> e.message print "cannot create connection with current driver" print
> >> "revise
> >> url and try again. Will exit application ..." sys.exit() def view(self):
> >> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT *
> >> FROM
> >> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); #
> >> Column
> >> 1 letter = rs.getString("letter"); # Column 2 name =
> >> rs.getString("name"); #
> >> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> >> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException,
> >> e:
> >> print e.message print "cannot open table" def close(self):
> >> self.db.close();
> >> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> >> app.close() alpha.db
> >>
> >>  Cheers!
> >>  Alfonso Reyes
> >> ________________________________
> >>  View this message in context: SQLite + JDBC + Jython. Example
> >>  Sent from the jython-users mailing list archive at Nabble.com.
> >>
> >> -------------------------------------------------------------------------
> >> This SF.net email is sponsored by: Splunk Inc.
> >> Still grepping through log files to find problems?  Stop.
> >> Now Search log events and configuration files using AJAX and a browser.
> >> Download your FREE copy of Splunk now >> http://get.splunk.com/
> >> _______________________________________________
> >> Jython-users mailing list
> >> Jython-users@...
> >> https://lists.sourceforge.net/lists/listinfo/jython-users
> >>
> >>
> >
> >
> > --
> > "De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
> > ments meg Uram minket!"
> >
> > http://www.freeweb.hu/pillesoft
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems?  Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@...
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >
> >
>
> --
> View this message in context: http://www.nabble.com/SQLite-%2B-JDBC-%2B-Jython.-Example-tf4663619.html#a13355517
> Sent from the jython-users mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>


--
"De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
ments meg Uram minket!"

http://www.freeweb.hu/pillesoft

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Ivan Horvath-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Alfonso,

some more information:
Microsoft SQL Server 2000 Driver for JDBC
     Service Pack 3
     Version 2.2.0040
     May 2004
this is the driver version

thank you for your help
Ivan

On 10/23/07, Ivan Horvath <pillesoft@...> wrote:

> Dear Alfonso,
>
> you can find the sample codes in a mail in this mail list. its subject
> is: another jdbc related question
> the driver is com.microsoft.jdbc.sqlserver.SQLServerDriver
> and here is the link for the setup.exe
> http://download.microsoft.com/download/4/1/d/41d3e9c0-64d1-451e-947b-7a4cba273b2d/setup.exe
>
>
> On 10/23/07, Alfonso Reyes <msfz751@...> wrote:
> >
> > Hi Ivan
> > I don't have experience with msde but I may be able to help you.
> > What is the driver that you use with msde? Could you send me a sample code
> > and a link to download the driver jdbc.msde?
> >
> > Thanks,
> > Alfonso
> >
> >
> >
> > Ivan Horvath-3 wrote:
> > >
> > > Dear Alfonso,
> > >
> > > i have some strange results when i tried to use msde with Jython. i
> > > posted some mail to the list, but there were no any answer. the
> > > subject of the mail: another jdbc related question
> > >
> > > it is about to get the databases from msde using zxJdbc, and orig.
> > > jdbc. i received different result.
> > >
> > > do you have any experience using other databases with Jython?
> > >
> > > thanks
> > > Ivan
> > >
> > > On 10/20/07, Alfonso Reyes <msfz751@...> wrote:
> > >>  The following is another basic example that illustrates the use of a
> > >> SQLite
> > >> driver for Java. Python already enjoys of a package for SQLite called
> > >> pysqlite but unfortunately is not callable from Jython. I am attaching
> > >> the
> > >> SQLite database alpha.db that is part of the example.
> > >>
> > >>  References:
> > >>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
> > >>  Tutorial:
> > >> http://www.pysquared.com/files/Java/JavaSQLiteExample/
> > >>
> > >>  Add to classpath or /jre/lib/ext:
> > >>  sqlitejdbc-v037-nested.jar
> > >>
> > >>  Sample Code: from java.sql import DriverManager from java.sql import
> > >> SQLException from java.lang import Class import sys class SQLiteDB: def
> > >> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> > >> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> > >> open(self): try: self.db = DriverManager.getConnection(self.url); stat1 =
> > >> self.db.createStatement() print self.db except SQLException, e: print
> > >> e.message print "cannot create connection with current driver" print
> > >> "revise
> > >> url and try again. Will exit application ..." sys.exit() def view(self):
> > >> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT *
> > >> FROM
> > >> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); #
> > >> Column
> > >> 1 letter = rs.getString("letter"); # Column 2 name =
> > >> rs.getString("name"); #
> > >> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> > >> "Code:", letter, "Name:", name, "\tCategory:", cat except SQLException,
> > >> e:
> > >> print e.message print "cannot open table" def close(self):
> > >> self.db.close();
> > >> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> > >> app.close() alpha.db
> > >>
> > >>  Cheers!
> > >>  Alfonso Reyes
> > >> ________________________________
> > >>  View this message in context: SQLite + JDBC + Jython. Example
> > >>  Sent from the jython-users mailing list archive at Nabble.com.
> > >>
> > >> -------------------------------------------------------------------------
> > >> This SF.net email is sponsored by: Splunk Inc.
> > >> Still grepping through log files to find problems?  Stop.
> > >> Now Search log events and configuration files using AJAX and a browser.
> > >> Download your FREE copy of Splunk now >> http://get.splunk.com/
> > >> _______________________________________________
> > >> Jython-users mailing list
> > >> Jython-users@...
> > >> https://lists.sourceforge.net/lists/listinfo/jython-users
> > >>
> > >>
> > >
> > >
> > > --
> > > "De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
> > > ments meg Uram minket!"
> > >
> > > http://www.freeweb.hu/pillesoft
> > >
> > > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by: Splunk Inc.
> > > Still grepping through log files to find problems?  Stop.
> > > Now Search log events and configuration files using AJAX and a browser.
> > > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > > _______________________________________________
> > > Jython-users mailing list
> > > Jython-users@...
> > > https://lists.sourceforge.net/lists/listinfo/jython-users
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/SQLite-%2B-JDBC-%2B-Jython.-Example-tf4663619.html#a13355517
> > Sent from the jython-users mailing list archive at Nabble.com.
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems?  Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@...
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >
>
>
> --
> "De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
> ments meg Uram minket!"
>
> http://www.freeweb.hu/pillesoft
>


--
"De sagittis hungarorum libera nos, Domine!" - "A magyarok nyilaitól
ments meg Uram minket!"

http://www.freeweb.hu/pillesoft

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: SQLite + JDBC + Jython. Example

by Moore, Greg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just a quick note.

Alfonso, I've already moved some of your examples to the
http://wiki.python.org/jython/DocumentationAndEducation section of the
wiki. I've mentioned that you were the one that posted them to the ML.
As Charlie suggested if you could post your examples to the wiki and
maybe an announcement here that would be great. I think your examples
are helpful and hope you continue.

Regards,
Greg.


-----Original Message-----
From: jython-users-bounces@...
[mailto:jython-users-bounces@...] On Behalf Of Charlie
Groves
Sent: Saturday, October 20, 2007 3:19 PM
To: Alfonso Reyes
Cc: jython-users@...
Subject: Re: [Jython-users] SQLite + JDBC + Jython. Example

Hi Alfonso,

It appears whatever Nabble is doing to format these when you're
posting them is lost when they're sent on to the mailing list.  The
code is a single block for me instead of multiple correctly indented
lines, and I imagine most people are seeing the same thing.  It'd
probably be better to add things like these to the examples section on
http://wiki.python.org/jython/DocumentationAndEducation anyway since
they can be kept up to date or improved there.

Charlie

On 10/20/07, Alfonso Reyes <msfz751@...> wrote:
>  The following is another basic example that illustrates the use of a
SQLite
> driver for Java. Python already enjoys of a package for SQLite called
> pysqlite but unfortunately is not callable from Jython. I am attaching
the

> SQLite database alpha.db that is part of the example.
>
>  References:
>  sqliteJDBC: http://www.zentus.com/sqlitejdbc/
>  Tutorial:
> http://www.pysquared.com/files/Java/JavaSQLiteExample/
>
>  Add to classpath or /jre/lib/ext:
>  sqlitejdbc-v037-nested.jar
>
>  Sample Code: from java.sql import DriverManager from java.sql import
> SQLException from java.lang import Class import sys class SQLiteDB:
def
> __init__(self): self.database = "alpha.db" driver = "org.sqlite.JDBC"
> self.url = "jdbc:sqlite:" + self.database Class.forName(driver); def
> open(self): try: self.db = DriverManager.getConnection(self.url);
stat1 =
> self.db.createStatement() print self.db except SQLException, e: print
> e.message print "cannot create connection with current driver" print
"revise
> url and try again. Will exit application ..." sys.exit() def
view(self):
> try: stmt = self.db.createStatement(); rs = stmt.executeQuery("SELECT
* FROM
> letters ORDER BY ID"); while (rs.next()): id = rs.getString("ID"); #
Column
> 1 letter = rs.getString("letter"); # Column 2 name =
rs.getString("name"); #
> Column 3 cat = rs.getString("categoryID"); # Column 4 print "ID:", id,
> "Code:", letter, "Name:", name, "\tCategory:", cat except
SQLException, e:
> print e.message print "cannot open table" def close(self):
self.db.close();

> if __name__ == '__main__': app = SQLiteDB() app.open() app.view()
> app.close() alpha.db
>
>  Cheers!
>  Alfonso Reyes
> ________________________________
>  View this message in context: SQLite + JDBC + Jython. Example
>  Sent from the jython-users mailing list archive at Nabble.com.
>
>
------------------------------------------------------------------------
-
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a
browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>

------------------------------------------------------------------------
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users


This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users