Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2004

Tip: Looking for answers? Try searching our database.

QUESTION: ODBC

Thread view: 
Christian Langis - 22 Sep 2004 22:15 GMT
Hi there.

I am currently learning Java (yes I know, it was about time to get
started). The book I use shows SQL examples reading some small databases
(4 columns, 5 rows). All these Java database SQL primitives are meant to
work only on JDBC-ODBC compliant databases (it is a 1997 book!). The
Java JDBC today is probably less restrictive. But I'll stick with the
book's stuff for now.

The question is: are there FREE tools on Windows to create such
databases files (which I could use later on my trivial Java examples)?
Or does MsExcel save files in such a database format?

Thanks
Nathan Zumwalt - 23 Sep 2004 19:06 GMT
You can setup ODBC data sources that point to Excel spread sheets or
even CSV files.  The JDBC/ODBC bridge can pick those up.

Personally, I would get a real database... it will be ultimately less
frustrating, and JDBC doesn't care if your using ODBC or not.  My
personal favorite is MySQL:

http://www.mysql.com/

//Nathan

> Hi there.
>
[quoted text clipped - 10 lines]
>
> Thanks
Fredrik Bertilsson - 24 Sep 2004 07:01 GMT
> Hi there.
>
[quoted text clipped - 10 lines]
>
> Thanks

Try http://hsqldb.sourceforge.net. It is a very nice java database.
You can use it  embedded in your application. No need for an external
process.

/Fredrik
Alex Kizub - 28 Sep 2004 20:19 GMT
Christian:
If you have choose Windows that's entirely your fault.
And it means that you have to work with Windows.
So, at least, create ODBC source (you can do it even for Excel *.xls
files (first row is collumn's names (if I'm not mistaken)))  :)))
register it with ODBC manager (for example with name EXCEL) and use
standard Java code like this:

import java.sql.*;

public class a {
      public static void main(String ar[]){
      // Load the JDBC-ODBC bridge driver

        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

      // setup the properties
      java.util.Properties prop = new java.util.Properties();
      //prop.put("charSet", "Big5");
      prop.put("user", "");
      prop.put("password", "");

      // Connect to the database quikdata
      Connection con =
DriverManager.getConnection("jdbc:odbc:EXCEL;UID=;PWD=", prop);
      System.out.println(con);

                Statement stmt = con.createStatement();
                if (stmt == null)
                    System.out.println ("ERROR: DBAccess: statement is null!");

            ResultSet rs = stmt.executeQuery("SELECT first_name, last_name, age
FROM users");
            while (rs.next()) {
                System.out.println(" " + rs.getString(1)+" " + rs.getString(2)+" "
+ rs.getString(3));
            }
            rs.close();

            stmt.executeUpdate("INSERT INTO users (first_name, last_name, age)
values ('Alex', 'Kizub', '99')");

       con.close();

        } catch (Exception ex) {
            System.out.println( ex.getMessage());
        }

      }
}

Even MS has more database like sources (like Access *.mdb or *.dbf)
it's better use more real like databases. But, of course, ODBC is good
too. Especially when you like to strugle with MS database
implementations :)

Alex Kizub.

> The question is: are there FREE tools on Windows to create such
> databases files (which I could use later on my trivial Java examples)?
> Or does MsExcel save files in such a database format?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.