Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

data feild storing in oracle database

 
lokesh rajarathnam
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all.,

I strucked in data storing to database, please push me out or this hurdel

import java.sql.*;

public class databaseconnecting
{

public databaseconnecting()
{
public String EFname=null;
public String EAddress=null;
public int Eage=0;
}

public dataconnect()
{ databaseconnecting dbc=new databaseconnecting();
try
{

Class.forname("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection ("jdbcdbc:MYDSNname","scott","tiger");
System.out.println("connected");
Statement stmt=con.createStatement();
int count=stmt.executeUpdate("insert into tablename (name,age,address) values"+" ('"+dbc.getName()+"',"+dbc.getAge()+",'"+dbc.getAddress+"')");
System.out.println("count=" +count);
}
catch(Exception ex)
{ System.out.println("connection faild");
}
}

public String getName()
{ EFname="myname";
return EFname;
}
public int getAge()
{
Eage=22;
return Eage;
}
public String getAddress()
{
EAddress="bangalore";
return EAddress;
}

public Static void main(String args[])
{
databaseconnecting dbc=new databaseconnecting();
dbc.dataconnect() ;
}
}


Issue: The values are not inserted in to the database(oracle).
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
What does it print? count=1? Or connection failed?
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Report post to moderator
Don't post same problem multiple times. That too in same forum!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue discussion in your other thread. I'll close this one for you.
 
    Bookmark Topic Watch Topic
  • New Topic