N
Navnath Gadakh
package javaapplication3;
import java.sql.*;
public class JavaApplication3 {
Connection con;
Statement st;
ResultSet rs;
public JavaApplication3()
{
connect();
}
public void connect()
{
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String db = "jdbcdbc:db1";
con = DriverManager.getConnection(db);
st = con.createStatement();
String sql = "select * from Table1";
rs = st.executeQuery(sql);
while(rs.next())
{
String fname = rs.getString("fname");
String lname = rs.getString("lname");
String address = rs.getString("address");
String email = rs.getString("email");
String mobile = rs.getString("mobile");
System.out.println(fname+lname+address+email+mobile);
}
}catch(Exception ex)
{
}
try
{
rs.moveToInsertRow();
rs.updateString("fname","abc");
rs.updateString("lname","xyz");
rs.updateString("address","mubmai");
rs.updateString("email","(e-mail address removed)");
rs.updateString("mobile","99854874154");
rs.insertRow();
st.close();
rs.close();
}
catch(Exception err)
{
System.out.println("Error!!!");
}
}
public static void main(String[] args) {
// TODO code application logic here
new JavaApplication3();
}
}
import java.sql.*;
public class JavaApplication3 {
Connection con;
Statement st;
ResultSet rs;
public JavaApplication3()
{
connect();
}
public void connect()
{
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String db = "jdbcdbc:db1";
con = DriverManager.getConnection(db);
st = con.createStatement();
String sql = "select * from Table1";
rs = st.executeQuery(sql);
while(rs.next())
{
String fname = rs.getString("fname");
String lname = rs.getString("lname");
String address = rs.getString("address");
String email = rs.getString("email");
String mobile = rs.getString("mobile");
System.out.println(fname+lname+address+email+mobile);
}
}catch(Exception ex)
{
}
try
{
rs.moveToInsertRow();
rs.updateString("fname","abc");
rs.updateString("lname","xyz");
rs.updateString("address","mubmai");
rs.updateString("email","(e-mail address removed)");
rs.updateString("mobile","99854874154");
rs.insertRow();
st.close();
rs.close();
}
catch(Exception err)
{
System.out.println("Error!!!");
}
}
public static void main(String[] args) {
// TODO code application logic here
new JavaApplication3();
}
}