Hello all, I am trying to learn some things about JDBC these days. I tried a couple of programs on my Win 2K professional platform using Java 2 (JDK 1.3) and the pre-installed "ODBC Data Source Administrator" program. However, I want to test these things on my Linux platform (SuSe 7.1 professional). Is there an equivalent app to "ODBC Data Source Administrator"? Any advice would be very helpfull. Thanx in advance, Tom.
Which database are you using? I use MySQL and I had to download the appropriate drivers and then include them in my classpath.
Tom Diamond
Ranch Hand
Joined: May 10, 2001
Posts: 98
posted
0
Well, I don't use a specific database.I just want to create a .dbf file and then update it using Java. The code I use is the following : //Start of CreateCoffees.java import java.sql.*; public class CreateCoffees { public static void main(String args[]) { String url = "jdbc dbc:dBASE Files"; Connection con; String createString; createString = "create table COFFEES " + "(COF_NAME VARCHAR(32), " + "SUP_ID INTEGER, " + "PRICE FLOAT, " + "SALES INTEGER, " + "TOTAL INTEGER)"; String add1 = "INSERT INTO COFFEES " + "VALUES ('Colombian', 101, 7.99, 0, 0)"; String add2 = "INSERT INTO COFFEES " + "VALUES ('Espresso', 150, 9.99, 0, 0)"; String add3 = "INSERT INTO COFFEES " + "VALUES ('Colombian_Decaf', 101, 8.99, 0, 0)"; String add4 = "INSERT INTO COFFEES " + "VALUES ('French_Roast_Decaf', 49, 9.99, 0, 0)";
Statement stmt; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "", ""); stmt = con.createStatement(); stmt.executeUpdate(createString); //Create dBase file stmt.executeUpdate(add1); //Modifying... stmt.executeUpdate(add2); stmt.executeUpdate(add3); stmt.executeUpdate(add4); stmt.close(); con.close(); } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } } } //End of CreateCoffees.java This thing creates a table stored in COFFEES.dbf and then adds some data into it. Watch line 3 :: I say "jdbc dbc:dBASE Files" because the "OBDC Data Source Administrator" program has linked "dBASE Files" with the appropriate driver. What will I have to write in a Linux platform? Thanx, Tom.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.