f



Newbie question: Importing .csv data into Java DB tables

I am trying to import five simple .csv files into separate Java DB
tables using NetBeans 5.5, but I can't seem to do it. This strikes me
as something that should be extremely basic, so I apologise in advance
for these overly simplistic questions.

1) How do I do it? I'd prefer to import the data from the .csv file,
rather than writing individual INSERT commands for each row in SQL.
2) Is it possible to save an Excel file as an .xml file (or even
a .csv file, or equivalent) and use THAT as a database table within
the app.?
2a) If (2) is 'yes', can the same be done using MS Access tables?

I'm open to any/all advice; if there's a website that spells all this
out in clear (lay-person) detail, I can try to work through that.  If
it's as simple as I think it should be, I'm grateful to anyone who can
offer their advice.

TIA,

GGP

0
chaoborid (5)
3/11/2007 11:27:55 PM
comp.lang.java.databases 3049 articles. 0 followers. samyaksulabh (16) is leader. Post Follow

3 Replies
2388 Views

Similar Articles

[PageSpeed] 15

"GGP" <chaoborid@yahoo.ca> wrote:

> I am trying to import five simple .csv files into separate Java DB
> tables using NetBeans 5.5, but I can't seem to do it. This strikes me
> as something that should be extremely basic, so I apologise in advance
> for these overly simplistic questions.

They're not as simple as it may seem, but as I haven't seen any answers to 
your question, I'll give it a try...

> 1) How do I do it? I'd prefer to import the data from the .csv file,
> rather than writing individual INSERT commands for each row in SQL.

There's no "standardized" way of importing in such a way into a database, as 
the DB's differ so much. Most "importing" rely on the DB's specific methods 
of doing such a thing.

The bottom line is that even if the possibility exist for some DB's, they're 
in practice mostly a simplified way of INSERTing the lines one by one behind 
the scenes.

I haven't used Java DB myself, but with a quick glance at their 
documentation, I would say that it should be possible by using Java DB's 
built-in procedures
SYSCS_UTIL.SYSCS_IMPORT_TABLE or SYSCS_UTIL.SYSCS_IMPORT_DATA

But on the other hand, why writing *individual* INSERT commands for each 
row? With a simple iteration you need to write the SQL INSERT only once, but 
iterating it for each line you read in from the csv.

> 2) Is it possible to save an Excel file as an .xml file (or even
> a .csv file, or equivalent) and use THAT as a database table within
> the app.?

Yes, it is, but you can even use Excel itself as a DB.

Just use an appropriate driver.

One way is to use Sun's built in ODBC-JDBC-bridge, and via that using 
Microsofts ODBC-driver for Excel. You can find tons of examples of that with 
Google.

> 2a) If (2) is 'yes', can the same be done using MS Access tables?

Absolutely, exactly the same thing goes for that as for (2), but then of 
course by using an ODBC-driver for the Jet database used by Access.

/// Bjorn A


0
Bjorn
3/26/2007 2:25:41 PM
On Mar 26, 9:25 am, "Bjorn Abelli"
<bjorn_abe...@DoNotSpam.hotmail.com> wrote:

Hi Bjorn,

Many thanks for your reply.  Sorry I didn't respond right away--I
thought this question had died in obscurity ;)

> I haven't used Java DB myself, but with a quick glance at their
> documentation, I would say that it should be possible by using Java DB's
> built-in procedures
> SYSCS_UTIL.SYSCS_IMPORT_TABLE or SYSCS_UTIL.SYSCS_IMPORT_DATA

I was not even aware that there were built-in facilities to import
data.  Thanks for the heads-up, I'll give it a go.

> Yes, it is, but you can even use Excel itself as a DB.
> Just use an appropriate driver.
>
> One way is to use Sun's built in ODBC-JDBC-bridge, and via that using
> Microsofts ODBC-driver for Excel. You can find tons of examples of that with
> Google.

Yes, I've started playing around with this, and it works like a
charm!  Again, thanks for the advice.  This is much more preferable to
working with .csv files.  I can get nearly everything I need into
Excel files, which (as you suggest) I can then access through code.

> Absolutely, exactly the same thing goes for that as for (2), but then of
> course by using an ODBC-driver for the Jet database used by Access.

Again, thanks.  I have a few large Access DBs that I'd prefer to keep
intact, as opposed to moving them to JavaDB (or whatever).  One quick
question, though: will the Access schema be respected when calling the
db from a Java app. using ODBC/JDBC bridge (haven't tried this yet--
just wondering if I should expect issues)?

Thanks again,

Greg.


0
GGP
4/3/2007 4:18:06 AM
"GGP" <chaoborid@yahoo.ca> wrote:

> Again, thanks.  I have a few large Access DBs that I'd prefer to keep
> intact, as opposed to moving them to JavaDB (or whatever).  One quick
> question, though: will the Access schema be respected when calling the
> db from a Java app. using ODBC/JDBC bridge (haven't tried this yet--
> just wondering if I should expect issues)?

There shouldn't be any problems.

I haven't had any major issues using Jet/Access in Java apps, though I 
*prefer* using databases with type 4 JDBC-drivers.

/// Bjorn A


0
Bjorn
4/3/2007 9:33:05 AM
Reply:

Similar Artilces:

Java Newbie question about Java POI
I was wondering if anyone has been working with ColdFusion 5.0 andJakarta POI - Java API To Access Microsoft Format Files. I have seenlots of information on using the POI with ColdFusion MX but my targetis ColdFusion 5.0.Any information on using the POI with ColdFusion 5.0 would beappreciated.Thanks in advance....

Java Newbie Question
Hello, This is my first post to this group and I am quite new to java. Here is the background to my question: - I have written in Java using Eclipse, a card game server. I accept client connections from an applet and add players to card games and they play cards. Wow, sounds great you must be thinking. Anyway I have been in talking to a hosting company about servers to host this on and was going to host on Linux (Redhat/Fedora). But the guy at the hosting recommended Windows Server 2003 because my website in .NET. So that leaves me the concern.. ...how reliable, fast, etc is running m...

Java + DB2, import table data
Hello, I've just started to work with DB2 (using the express edition version 9.5 under windows vista) and I'm accessing it through a java program (my java's very rusty). The java program loads the driver, connects and tries to create two tables. That works just fine. Then it tries to import data into one of the tables but it seems I can't use an import command with Statement.execute() because an exception is thrown if I attempt to do this. Is this possible and, if so, how? Here's the acutal call that triggers the exception: statement.execute("IMPORT FROM 'C:/staff.xml.xsd' OF DEL METHOD P(1) MESSAGES 'C:/messages.txt' INSERT INTO STAFF_AS_XML (STAFF_AS_XML_COL);"); One of the tables has a single xml column and I have an xml-file I want to import to that table from the java program. The command works under control center (but not always, which is weird, but that is a separate issue). Thanks for reading and thanks for any replies. WP wrote: > Hello, I've just started to work with DB2 (using the express edition > version 9.5 under windows vista) and I'm accessing it through a java > program (my java's very rusty). The java program loads the driver, > connects and tries to create two tables. That works just fine. Then it > tries to import data into one of the tables but it seems I can't use > an import command with Statement.execute() because an exception is > throw...

java.lang.Set with elements of type java.lang.Set
Roughly I do something along the lines of: Set set = new HashSet(); Set elem = new HashSet(); set.add(elem); // now we change the elem and add it again to the set elem.add(some object here); set.add(elem); I found out the hard way that 'set' may now contain 'elem' either once or twice, the reason being that 'elem.add()' changes the hashCode of elem such that it is not noticed that it is in 'set' already on the 2nd 'set.add()'. Question: What I would actually want is an IdentityHashSet() set = new IdentityHashSet() but this does not...

Newbie Question: Copying A Record's Data From Multiple Tables In One Database to Another
Greetings Access Users, I have a database that has a record that I wish to copy from one database to another. The table structures in the two databases are identical. Here's the issue: the record's data is broken up into about 10 related tables. Is there any hints or tips on the best way of writing a query or some other solution to acheive this copy? I have about 70 records to copy from one database to another, and if I have to manually re-enter the data, it would take days. Thanks a million in advance, any advice that solves this matter would be a life saver! Kevin "No Spam" <nospam@earthlink.net> wrote in message news:ohs7c115dg4nds12hv9n70627s9db9p9b6@4ax.com... > Greetings Access Users, > > I have a database that has a record that I wish to copy from one > database to another. The table structures in the two databases are > identical. Here's the issue: the record's data is broken up into > about 10 related tables. Is there any hints or tips on the best way > of writing a query or some other solution to acheive this copy? > > I have about 70 records to copy from one database to another, and if I > have to manually re-enter the data, it would take days. > > Thanks a million in advance, any advice that solves this matter would > be a life saver! > In your source database, create a link to you destination table (linked table manager), then use an append query with the linked table as ...

Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object
Good day to all, I have installed the j2se/netbeans binary bundle on red hat 9. I can run everything perfectly as root but when I try to compile with any other user I get: Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object When I saw this it seemed like a permissions problem but I checked the permissions and everything seemed fine. All users have execute permissions of javac and java. I have read other threads dealing with the same or similar problem but have not reached any solution yet. I would appreciate if anyone that has run into this type of problem and has solved it if he/she could give me a hand or if anyone could just point out what I should be looking for in this type of problem. Thanks in advance... gek ...

java.lang vs java.util
Surprising to see something defined in java.lang <http://developer.android.com/reference/java/lang/Iterable.html> depend on something defined in java.util <http://developer.android.com/reference/java/util/Iterator.html>. Surely the hierarchy should go the other way? On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote: > Surprising to see something defined in java.lang > <http://developer.android.com/reference/java/lang/Iterable.html> depend on > something defined in java.util > <http://developer.android.com/reference/java/util/Iterator.html>. > > Surely the hierarchy should go the other way? I think Iterable may make it into java.lang because of its significance in the foreach statement. Patricia On 04/02/2011 12:23 AM, Patricia Shanahan wrote: > On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote: >> Surprising to see something defined in java.lang >> <http://developer.android.com/reference/java/lang/Iterable.html> depend on >> something defined in java.util >> <http://developer.android.com/reference/java/util/Iterator.html>. >> >> Surely the hierarchy should go the other way? Not if it wants to be consistent with http://download.oracle.com/javase/6/docs/api/ don't'cha think? And the so-called "hierarchy" of java.util and java.lang is that they are equal. The language reserves for itself the entire panoply of java.* and javax.* packages. > I think It...

Java and Java EE Interview Questions
Hello everybody!! I have a compilation of frequently asked and not so frequently asked interview questions in Java and Java EE and popular open source technologies.Even if you are not appearing for interview this will help you build and enhance your insight and knowledge base on Java technologies. Your comments and suggestions are welcome. http://interviewjava.blogspot.com/ Regards, Dharmendra On Mar 19, 8:10=A0pm, Dharmendra <dharmendra.pund...@gmail.com> wrote: > Hello everybody!! > > I have a compilation of frequently asked and not so frequently asked > interview ques...

Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please reply with YES or NO.
Hi, Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please put YES or NO as the first word in your reply. Add comments after it if you wish. I'll make a YES/NO count after some time. Kind regards, Paka Paka Small wrote: > Poll: Is a Java Method an Instance of the Java Class > java.lang.reflect.Method? It's not subject to vote. It's defined by the language. You might as well ask, "Is 'int' a primitive or a reference type?". Your vote will not change reality. > Please put YES or NO as the first word in your reply. Add comments > after it if you wish. > > I'll make a YES/NO count after some time. And what exactly do you hope to accomplish by this exercise? Distinguish who knows Java from those who don't? A method is not a class, and a class is not a method. That's reality in Java. The law of gravity is not subject to repeal by opinion, and neither is this. Instead of wasting your time and trying to waste ours conducting meaningless polls, why don't you read the material linked upthread and learn the truth for yourself? Learn the truth and it will set you free, or at least keep you from making errors like claiming that methods and classes are the same in Java. -- Lew On 5 feb, 20:38, Lew <lewbl...@gmail.com> wrote: > Paka Small wrote: > > Poll: Is a Java Method an Instance of the Java Class > > java.lang.reflect.Method? > > It's not sub...

Newbie question
Hi, This is a very newbie question on Java. I am doing the Java tutorials on java.sun.com and came across an example where I need to compile 3 java files (CreateObjectDemo.java which uses Point.java & Rectangle.java) at the same time. #Files are found at the end of the mesg# It says that I need all 3 files to compile. How do I do this? From the command line with 'javac'? Or can use the 'import' function in the CreateObjectDemo.java file? If yes, how? Thanks a lot! TS. CreateObjectDemo.java ===================== public class CreateObjectDemo { public static void main(String[] args) { // create a point object and two rectangle objects Point origin_one = new Point(23, 94); Rectangle rect_one = new Rectangle(origin_one, 100, 200); Rectangle rect_two = new Rectangle(50, 100); // etc, etc, etc - code truncated } Point.java ========== public class Point { public int x = 0; public int y = 0; // a constructor! public Point(int x, int y) { this.x = x; this.y = y; } } Rectangle.java ============== public class Rectangle { public int width = 0; public int height = 0; public Point origin; public Rectangle() { origin = new Point(0, 0); } // etc, etc, etc - code truncated } TS123 wrote: > Hi, > > This is a very newbie question on Java. > > I am doing the Java tutorials on java.sun.com and came across an > example where I need to compile 3 java files (CreateOb...

JAVA lang question.
Hello,What does "String a : args" mean in the following code snippet:public class FindDups { public static void main(String[] args) { Set<String> s = new HashSet<String>(); for (String a : args) if (!s.add(a)) System.out.println("Duplicate detected: " + a); System.out.println(s.size() + " distinct words: " + s); }}J Leonard John.Leonard@_remove_before_sending_gmail.com wrote:> Hello,> > What does "String a : args" mean in the following code snippet:> > public class FindDups {...

Newbie Java Question
I hope I'm in the right newsgroup to ask this question; I apologize if I'm not. I have a Windows XP machine, but no Java installed. I obviously have problems with web sites that use Java Scripts. When I visit Microsoft's web site to find out how to get Java, I'm bombarded with information that is nothing but technical gobblygook to me (I am NOT a PC programmer/techie type, and don't understand what the hell Microsoft is talking about). However, if I'm reading it right, Microsoft seems to say that Java is no longer available or supported. Can someone PLEASE tell me: 1...

CheckBox in Column of JTable: Exception: java.lang.String cannot be cast to java.lang.Boolean
Hello, I have discovered a hidden error. My project was working for awhile, but then I started to get the below error. My error comes from the fact that I'm using a checkbox in a jtable, and I'm using the below "getColumnClass". Thank you, compile: run: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(JTable.java:5412) at javax.swing.JTable.prepareRenderer(JTable.java:5735) at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2114) at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2016) at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1812) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161) at javax.swing.JComponent.paintComponent(JComponent.java:778) at javax.swing.JComponent.paint(JComponent.java:1054) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413) at javax.swing.RepaintManager.paint(RepaintManager.java:1206) at javax.swing.JComponent._paintImmediately(JComponent.java:5169) at javax.swing.JComponent.paintImmediately(JComponent.java:4980) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770) at javax.swing.RepaintM...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

java.lang.IllegalStateException: No Java compiler available
tearing my hair out on this one.Thuis started as an upgrade issue till i realised that my un-usedtomcat5 installation didn't work either with my test jsp.I have, in desparation, un-installed all java / tomcat libs and re-installed only those required to get thetomcat6-6.0.14-1jpp.noarch.rpm (and the band-waggon) loadedfirst I installed java_app_platform_sdk-5_02-linux.binthis shows (after I set alternatives to point to the /opt/SDK/jdkdirecrtory)[root@squirrel ~]# javac -versionjavac 1.6.0java shows the same.I have set the following in profileCLASSPATH=$JDKHOME:$JDKHOME/lib/tools.jarJAVA_H...

java.io.File to java.lang.String
What's the best way to get the contents of a file represented by ajava.io.File object into a String? Benjamin wrote:> What's the best way to get the contents of a file represented by a> java.io.File object into a String?> You don't specify what you consider best so how about simple as best? Now for my curiosity, why would you want to do this?import java.io.*;public class test { public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); File f = new File(args[0]); FileInputStream fis = new ...

java 101 question
working entirely from the as400 green screen .... I create a stream file with some java source code: class Example { public static void main( String args[]) { System.out.println( "This is a simple Java program." ) ; } } file name is /home/srichter/java/java01.class I compile the program: CD DIR('/home/srichter/java') CRTJVAPGM CLSF(java01.class) ========> first question: the program compiles successfully. Where does the system place it? After the compile the /home/srichter/java directory does not contain any new object. just the one source file. Now I want to run this program ( from the green screen ) CD DIR('/home/srichter/java') RUNJVA CLASS(java01.class) CLASSPATH(Example) I try all different variations on the theme of running the java01 class file and the Example class it contains with no success. A lot of "NoClassDefFoundError" errors. How do I run my simple java program? thanks, Steve Richter Steve Richter wrote: > working entirely from the as400 green screen .... > > I create a stream file with some java source code: > > class Example { > public static void main( String args[]) { > System.out.println( "This is a simple Java program." ) ; > } > } > > file name is /home/srichter/java/java01.class > > I compile the program: > CD DIR('/home/srichter/java') > CRTJVAPGM CLSF(java01.class) > > =...

newbie java question.. printf...
What should I have imported so that System.out.printf and System.out.println would compile? I get error messages like cannot find symbol. SpreadTooThin wrote: > What should I have imported so that System.out.printf and > System.out.println would compile? > I get error messages like cannot find symbol. Nothing. System is in java.lang and that is always imported implicit (even though explicit is allowed). What is the error message you get? (printf requires 1.5 or higher) Arne On May 20, 7:06=A0pm, Arne Vajh=F8j <a...@vajhoej.dk> wrote: > SpreadTooThin wrote: > > ...

Newbie question about Java book.
Saw "Java How to Program (7th Edition)" at my local book store. Looked it up online and saw six reviews that all were pretty favorable. Anyone else have any hands on with this book? Before I shell out $90 for a book, I would like to be sure it is worth while. As a side note, I hate online books, I like having a physical book sitting next to me as I program. Just easier for me, and how I learned in the past. Thanks in advance for your feedback. -Lee "Lee" <lawentzel@gmail.com> wrote in message news:1188237364.787912.294080@50g2000hsm.googlegroups.com... > S...

java daemon
In java to make a daemon can you fork() and close the parent process ? I cannot find fork() method. In Java you create a thread and set it's daemon flag to true. Look in the Java docs under Thread mthlv12 wrote: > In java to make a daemon can you fork() and close the parent > process ? I cannot find fork() method. ...

java/jython
Hi, I'm trying to teach myself a bit of jython and I am trying to run the code below. But I keep on getting the error message: "package org.python.util does not exist import org.python.util.PythonInterpreter; " When I try to compile it. Any ideas would be appriciated. Thanks! import org.python.util.PythonInterpreter; import org.python.core.*; public class SimpleEmbedded { public static void main(String []args) throws PyException { PythonInterpreter interp = new PythonInterpreter(); System.out.println("Hello, brave new world"); i...

Newbie question on Java terminology
Hello, I have started using the IntelliJ IDEA Java JDK from jetbrains.com. The IntelliJIDEA tool uses things like Project, Module, Package etc. I would really appreciate if someone could confirm whether or not this is standard Java terminology, and in case it is, I would request a small description on each. Thanks, Hayato [So proud of our women's football team] On 7/20/2011 7:04 AM, Proud Japanese wrote: > I have started using the IntelliJ IDEA Java JDK from jetbrains.com. > The IntelliJIDEA tool uses things like Project, Module, Package etc. package: <http://download.oracle.com/javase/tutorial/java/package/packages.html> Like the "package" statement is standard. The other two term are not really Java terms at all but imo belong to an ad-hoc collection of terms commonly used in the software engineering community. IntelliJ is probably using them just the way everyone else does. On Jul 20, 8:27=A0am, markspace <-@.> wrote: > On 7/20/2011 7:04 AM, Proud Japanese wrote: > > > I have started using the IntelliJ IDEA Java JDK from jetbrains.com. > > The IntelliJIDEA tool uses things like Project, Module, Package etc. > > package: > > <http://download.oracle.com/javase/tutorial/java/package/packages.html> > > Like the "package" statement is standard. > > The other two term are not really Java terms at all but imo belong to an > ad-hoc collection of terms commonly used in the softw...

java error message java.io not found in import
Hi i'm trying to run a code like but i'm getting all the time the same error Class java.io not found in import import Java.io i guess the problem is that i dont have the header in the include folder,doenst anyone have solution for me? thread wrote: > Hi i'm trying to run a code like but i'm getting all the time the same > error > Class java.io not found in import > import Java.io 1. Capitalization matters. The package name is `java.io', not `Java.io' 2. The first-person subjective pronoun is `I', not `i'. 3. There is no class `java.io'; there is a package `java.io' which contains such useful classes as Reader or Writer... Perhaps you wanted to import all of java.io, in which case the syntax is `import java.io.*' -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth On May 15, 9:55=A0pm, thread <yaniv...@gmail.com> wrote: > ...i'm trying to run a code like but i'm getting all the time the same > error > Class java.io not found in import > import Java.io > > i guess the problem is that i dont have the header in the include > folder,doenst anyone have solution for me? Try starting here(1) and here(2) (1) <http://pscode.org/javafaq.html#exact> (2) <http://pscode.org/sscce.html> For example, this is an SSCCE.. <SSCCE> import java.io; class TestCompile { } </SSCCE> ...and here is the *exact* error message &l...

Web resources about - Newbie question: Importing .csv data into Java DB tables - comp.lang.java.databases

Resources last updated: 3/29/2016 2:31:18 PM