Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

problem in entering values

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii..thnks for ur advice
this time i have used for
enterin values
but again the program is compiling but
values r not entered..plzz help

import java.sql.*;

public class buffer


public static void main(String [] args)

String ss;
ss = getLine();
ss = ss.trim();
if (ss.charAt(0) == 'q') System.exit(0);

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();

//these two statements does not execute durin the program

int m;

m= st.executeUpdate("insert into mayank values(ss) ");

ResultSet rs;

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



String n= rs.getString("name");
String c = rs.getString("class");
System.out.println(n + " " + c);


catch (Exception e)

/*System.err.println("Got an exception! ");

} // end main
* reads a line from STDIN
public static String getLine () {
StringBuffer buf = new StringBuffer(80);
int c;
try {
while ((c = != -1) {
char ch = (char) c;
if (ch == '\n') break;
catch (IOException e) {
return (buf.toString());
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

insert into mayank values(ss)

That is not valid SQL. Assuming you are trying to enter a record into a table called "mayank" that has only one column which is a character datatype it should probably be this:

Thinks to note: its not good practice to comment the code which logs an exception message. Without the exceptions message all you can do is guess.

Its a good idea to post the exception message you see when you create a topic; it helps those who might respond.

Please don't post topics using abbreviated language (ur, r, plzz etc.) - it makes you posts difficult to read.
Posts: 67389
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

Forum Bartender
Danger, 10,000 volts, very electic .... tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic