Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with simple JDBC2.0 code

0 views
Skip to first unread message

Ba...@burd.org

unread,
Jul 26, 2000, 3:00:00 AM7/26/00
to
This is yet another "why-doesn't-this-code-work" posting. Here's the
code:

import java.sql.*;

public class DBinsertRow {
static Connection connection;
static Statement statement;
static ResultSet resultset;

public static void main(String args[])
throws SQLException, ClassNotFoundException,
InstantiationException, IllegalAccessException {

Driver drv = (Driver) Class.forName
("JData1_2.sql.$Driver").newInstance();
connection =java.sql.DriverManager.getConnection(
"jdbc:JDataConnect://127.0.0.1/OurEmployees");
statement = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultset = statement.executeQuery("SELECT * FROM EMPLOYEES");

resultset.moveToInsertRow();
resultset.updateString("NAME", "Burd");
resultset.updateString("ID", "33333");
resultset.updateInt("RANK", 2);
resultset.updateFloat("SALARY", 10.00f);

resultset.insertRow();


resultset.close();
statement.close();
connection.close();
}

}

Here's the error message:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error
in row
at JData1_2.sql.$Connection.FromServer($Connection.java:855)
at JData1_2.sql.$Connection.ToServer($Connection.java:996)
at JData1_2.sql.$ResultSet.Send($ResultSet.java:359)
at JData1_2.sql.$ResultSet.insertRow($ResultSet.java:930)
at DBinsertRow.main(DBinsertRow.java:25)
Exception in thread "main"

And here's the code that created the table:

import java.sql.*;

public class DBcreateTable {
static Connection connection;
static Statement statement;

public static void main(String args[])
throws SQLException, ClassNotFoundException {

//put back in out of expediency:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


connection = DriverManager.getConnection
("jdbc:odbc:OurEmployees","sysdba", "masterkey");
statement = connection.createStatement();

statement.executeUpdate("create table " +
"EMPLOYEES (NAME VARCHAR(32)," +
"ID VARCHAR(5) NOT NULL PRIMARY KEY," +
"RANK INTEGER," +
"SALARY FLOAT)");
statement.executeUpdate("insert into EMPLOYEES" +
" values('Barry', '12345', 1, 25000.00)");
statement.executeUpdate("insert into EMPLOYEES" +
" values('Harriet', '54321', 2, 20000.00)");


statement.close();
connection.close();
}

}

I'm using JDataConnect.

Thanks in advance to anyone with suggestions.


Sent via Deja.com http://www.deja.com/
Before you buy.

Sascha Frevel

unread,
Jul 27, 2000, 3:00:00 AM7/27/00
to
I have had the same problem. Which ODBC driver do you use? Try the newest
one from MS.

And change this line

("JData1_2.sql.$Driver").newInstance();

to

("JData2_0.sql.$Driver").newInstance();

Sascha


Ba...@Burd.org schrieb:

Ba...@burd.org

unread,
Aug 2, 2000, 3:00:00 AM8/2/00
to
In article <397FC7AB...@i-punkt-software.com>,

Fre...@i-punkt-software.com wrote:
> I have had the same problem. Which ODBC driver do you use? Try the
newest
> one from MS.
>

I downloaded ODBC 3 but, when I try to run ODBCINST.EXE, I get a
message reporting Error 0x485, and nothing else happens. Any ideas?

> And change this line
>
> ("JData1_2.sql.$Driver").newInstance();
>
> to
>
> ("JData2_0.sql.$Driver").newInstance();
>

I tried making this change. No luck so far.

0 new messages