This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jdbc--sql exception invalid object 'objectname"  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
below is a code to store data in a database...it gives an exception invalid object name 'Shopper2'..........Shopper2 is a table in sql database......i used create table statement
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
class Shopping implements ActionListener
{
static JFrame f1;
static JPanel p1;
JLabel shopperName;
JLabel shopperAddress;
JTextField tShopperName;
JTextField tShopperAddress;
JButton b1;
public static void main(String args[])
{
new Shopping();
}
public Shopping()
{
p1 = new JPanel();
f1 = new JFrame("Storing Data in a Datbase");
f1.setVisible(true);
f1.setSize(300,300);
f1.getContentPane().add(p1);
shopperName = new JLabel("Name");
shopperAddress = new JLabel("Address");
b1 = new JButton("Submit");
tShopperName = new JTextField(10);
tShopperAddress = new JTextField(10);
p1.add(shopperName);
p1.add(shopperAddress);
p1.add(tShopperName);
p1.add(tShopperAddress);
p1.add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent evt)
{
Object source = evt.getSource();
if(source == b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
con=DriverManager.getConnection("jdbc dbc:HR","user1","");
PreparedStatement stat =con.prepareStatement("insert into Shopper2(vName,vAddress) values(?,?)");
stat.setString(1,tShopperName.getText());
stat.setString(2,tShopperAddress.getText());
stat.executeUpdate();
}
catch(Exception e)
{
System.out.println("Error" + e);
}
}
}
}

thank u very much...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!