Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Databases
»
JDBC and Relational Databases
"ssd=rs.getString("Valid_From");" is having some error
Harsh Girdhar
,
Greenhorn
Jul 17, 2012 14:46:57
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
package jtabledatabase; import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.*; import java.applet.*; import java.sql.*; import java.awt.ItemSelectable; import java.awt.event.ItemListener; public class Jtabledatabase extends JFrame implements ActionListener ,ItemListener { public static void main(String args[]) { new Jtabledatabase(); } Connection con; Statement st; ResultSet rs; JLabel l1,l2,l3,l4; JTextField t2,t3,t4; JButton b1,b2; Choice cb; JCheckBox cb1; String s1,s2,s3; Jtabledatabase() { l1=new JLabel("Subject Name"); l2=new JLabel("Valid From"); l3=new JLabel("Valid To"); l4=new JLabel("Semester"); t2=new JTextField(15); t3=new JTextField(15); t4=new JTextField(15); b1=new JButton("Save"); b2=new JButton("Cancel"); cb=new Choice(); cb.addItem("--Select--"); dbOpen(); try { st=con.createStatement(); rs=st.executeQuery("Select Subject_Name from CMS_SUBJECT"); while(rs.next()) { cb.addItem(rs.getString("Subject_Name")); } dbClose(); dbOpen(); } catch(Exception e) { e.getMessage(); } l1.setBounds(20,20,100,30); l2.setBounds(20,60,100,30); l3.setBounds(20,100,100,30); l4.setBounds(20,160,100,30); t2.setBounds(160,60,100,30); t3.setBounds(160,100,100,30); t4.setBounds(160,160,100,30); b1.setBounds(40,250,100,30); b2.setBounds(160,250,100,30); cb.setBounds(160, 20, 150, 30); cb1=new JCheckBox("Is_Active"); cb1.setBounds(20,200,100,30); setLayout(null); add(l1); add(l2); add(l3); add(l4); add(cb); add(t2); add(t3); add(t4); add(b1); add(b2); add(cb1); b1.addActionListener(this); b2.addActionListener(this); cb.addItemListener(this); setSize(450,350); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void itemStateChanged(ItemEvent event) { String obj = cb.getSelectedItem(); //if(event.getStateChange() == ItemEvent.SELECTED) //{ try { String ssd=""; st=con.createStatement(); System.out.println("haryas"); String seltabele="Select *from CMS_SUBJECT where Subject_Name='obj'"; rs=st.executeQuery(seltabele); System.out.println("hary"+obj); while(rs!=null) { System.out.println("hary inside"); ssd=rs.getString("Valid_From"); System.out.println(ssd); rs.next(); } System.out.println(ssd); dbClose(); dbOpen(); } catch(Exception e) { e.printStackTrace(); System.out.println("hary"); } //} } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b2) { this.setVisible(false); } else if(ae.getSource()==b1) { try { st.executeUpdate("INSERT INTO CMS_SUBJECT(Valid_From,Valid_To,Semester,Is_Active)" + "VALUES('" + t2.getText() + "','" + t3.getText() + "'," + t4.getText() + ","+cb.isEnabled()+")"); System.out.println("Mission pura hua"); setText(); dbClose(); dbOpen(); } catch(Exception e) { e.printStackTrace(); } } } public void dbOpen() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:CMSDatabase"); st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rs = st.executeQuery("Select * from CMS_SUBJECT"); if(rs.next()) setText(); } catch(Exception e) { System.out.println("1"+e.getMessage()); } } public void dbClose() { try { con.close(); rs.close(); st.close(); } catch(Exception e) { System.out.println("2"+e.getMessage()); } } public void setText() { t2.setText(""); t3.setText(""); t4.setText(""); } }
Paul Clapham
,
Marshal
staff
Jul 17, 2012 15:17:13
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Line 110 isn't right.
Harsh Girdhar
,
Greenhorn
Jul 18, 2012 11:48:06
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Thanxx frnds .. The issue has been solved
Post by:
autobot
crispy bacon. crispy tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 952 times.
Similar Threads
why its not running or how to run it
Can't Update Record ?
Can't Update Record ?
Getting sql error [Microsoft ][odbc microsoft access driver]numeric index out of range
The INSERT INTO statement contains the following unknown field name: 'OPANo'.
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:43:02
.