Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 3rd, 2003, 02:34 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
importing Excel and Access data with JDBC

I'm researching this subject at this time as I am building an application based on Java and PostgreSQL and I would like to be able to import Access and Excel files into it .

I've read about JDBC that it works with ODBC , however i've never had to implement such a thing , and as a matter of fact , i've never worked with any database / developing tools in Windows , nor have I ever connected JDBC to a file as oposed to a database server / service .

So I thought it would not hurt to shoot a question here as I continue my research on the matter . Any sugestions are welcome

Thanks

Reply With Quote
  #2  
Old May 4th, 2003, 03:25 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
For Excel you can use the great POI project to read Excel files and convert them to whatever you want (I have experimented with Excel <-> database insertion and extraction).
Access will be a bit more difficult, you'll need at least a windows PC and Sun jdbc-odbc bridge or RMIJdbc driver.

Reply With Quote
  #3  
Old May 4th, 2003, 12:49 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
so there is no way of dooing this with a single FreeBSD application server ?

Reply With Quote
  #4  
Old May 4th, 2003, 02:01 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
Yes, for Excel, probably not for Access.
Don't kow if the jdbc-odbc bridge works for UnixODBC, in that case there is an UnixODBC driver for Access on Sourceforge.
It has been used to show records from Access with Php on Linux.

Reply With Quote
  #5  
Old May 4th, 2003, 02:04 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
many thanks , it looks like u've sent me in a few good directions ...

i'll let you know how it all went

Reply With Quote
  #6  
Old May 5th, 2003, 12:16 AM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
one more thing ...
i understand there is a way to convert an access database into a flat file of some sort ... would there be a way to read that file with jdbc ?

Reply With Quote
  #7  
Old May 5th, 2003, 02:57 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
Yes, there is a jdbc driver for csv files on Sourceforge
CSVJdbc
Wait, I found a jdbc driver for Excel -> xlsjdbc
Please, tell me if xlsjdbc works!!

Reply With Quote
  #8  
Old May 5th, 2003, 07:47 AM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
thanks a lot i'll keep you posted

Reply With Quote
  #9  
Old May 5th, 2003, 12:49 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
Hi , surprinsingly after a few hours of play and reading through the drivers source code i've come up with the following ( from my understanding this is preety much all it does ) :

Code:
import java.sql.*;
import java.util.*;

class Conx
{
        public static Connection con = null;

        public static void main ( String [] args )
        {
        try {
        Class.forName("org.aarboard.jdbc.xls.XlsDriver").newInstance();
        con = DriverManager.getConnection("jdbc:aarboard:xls:/java/ExcelImporter/work" );

        Statement stmt;
        ResultSet rs;

        stmt = con.createStatement();

        rs = stmt.executeQuery("Select * from m");
        rs.next();
        System.out.println("This shold not appear here cuz i'm a noob :" +
                                rs.getString("CatID"));

            }
        catch ( Exception e ) {
        e.printStackTrace();
        return;
                              }
        }
}


luckly javac Conx showed me :

This shold not appear here cuz i'm a noob :2

Doesn't seem to support types or any other queries other than "select * from xlsfilename" but for me it's enough ...

Last edited by zapa : May 5th, 2003 at 12:51 PM.

Reply With Quote
  #10  
Old May 5th, 2003, 05:29 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
Nice, thanks!
Unfortunately looks like I'll have to stick to POI (more complex excel files).

Reply With Quote
  #11  
Old May 6th, 2003, 07:35 AM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
oops
Code:
-rw-r--r--  1 zapa  www    31873536 May  5 20:40 ab.xls
j# java Conx
Exception in thread "main" java.lang.OutOfMemoryError


The file has about 100 000 rows each with some 60 columns . Now I'm a noob so I'd have to ask .

It looks so far that the file is too big for the drivers 'select * from filename' limitation .

Now do you guys have any sugestions ? Is there anything i could do to optimise it somehow and make it work ?

Any input would be much appreciated

Reply With Quote
  #12  
Old May 6th, 2003, 01:44 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
Don't know, maybe it's trying to load everything into memory which can be a problem, you might want to try Jakarta POI to manipulate Excel files.

Reply With Quote
  #13  
Old May 6th, 2003, 02:09 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa

yepp I was just going to do that for this one file . Rest of the files i need to work with seem to be fine ...

i just wanted to make sure , i'm not dooing anything wrong myself since i'm new to java & jdbc so there is allwais that chance

Reply With Quote
  #14  
Old May 9th, 2003, 12:17 PM
zapa zapa is offline
Mentat of IX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucuresti / Toronto
Posts: 112 zapa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 sec
Reputation Power: 6
Send a message via ICQ to zapa
btw pabloj , your links are great , I've installed fabForce and it looks really nice , i'll get to use it quite a bit over this weekend

Reply With Quote
  #15  
Old May 9th, 2003, 03:38 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 7 m 10 sec
Reputation Power: 279
Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > importing Excel and Access data with JDBC


Thread Tools  Search this Thread