File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes problem in enterin data through jdbc:odbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem in enterin data through jdbc:odbc" Watch "problem in enterin data through jdbc:odbc" New topic

problem in enterin data through jdbc:odbc

mayank yadav

Joined: Sep 25, 2005
Posts: 11
i have just started with JDBC
i tried a simple program for viewing and entring
values in MS the below code i can retrieve
the values but cannot enter .....plzzz help

import java.sql.*;
import java.awt.*;

class Net2

public static void main(String ar[])

try {

// Step 1: Load the JDBC driver.

// Step 2: Establish the connection to the database.
String url = "jdbc dbc:mayank";
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
ResultSet rs ;

//these two statements does not execute durin the program

//int m;

//st.executeUpdate("insert into mayank values('NITS') ");

rs = st.executeQuery("select class from mayank ");





catch (Exception e)

/*System.err.println("Got an exception! ");
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

There is a problem wit hteh Type 1 Driver which causes it to 'cache' quesries and not pass them to the database. You can search this forum for other solutions, but one fix is here.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381

Known Access issues aside there are two major problems with the code you posted. The first is a SQL issue. When you have the following query

that assumes that the table mayank only has one column/field. If it has more than one then this query will not work.

based on how you do the SELECT later on I think your insert query should be

The second problem in your code is even more severe. The line where you are executing your update (in this case INSERT SQL) has been commented out.
mayank yadav

Joined: Sep 25, 2005
Posts: 11
thanks ....
it really worked...
please advice me how to procede
further in passing values from an applet
to this application..
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

The applet part of this question is being discussed in the Applets forum.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: problem in enterin data through jdbc:odbc
It's not a secret anymore!