File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes data feild storing in oracle database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

data feild storing in oracle database

lokesh rajarathnam
Ranch Hand

Joined: May 17, 2007
Posts: 35
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

Joined: Oct 27, 2005
Posts: 19784
    
  20

What does it print? count=1? Or connection failed?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Don't post same problem multiple times. That too in same forum!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

Please continue discussion in your other thread. I'll close this one for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: data feild storing in oracle database