Showing posts with label rowset. Show all posts
Showing posts with label rowset. Show all posts

Monday, 20 June 2016

JDBC PROGRAM TO WORK WITH CachedRowSet

JDBC PROGRAM TO WORK WITH  CachedRowSet

import com.sun.rowset.*;

import java.io.*;

class ChacheRowSetImpl

{

public static void main(String[] args) throws Exception
{
Class.forName("com.mysql.jdbc.Driver");

CachedRowSetImpl cr=new CachedRowSetImpl();

cr.setUsername("root");
cr.setPassword("root");
cr.setUrl("jdbc:mysql://localhost:3306/voidmain");

cr.setCommand("select * from account");

cr.execute();

FileOutputStream fos=new FileOutputStream("D:\\cached.txt");

ObjectOutputStream os=new ObjectOutputStream(fos);

os.writeObject(cr);

}
}

=======================================================================

import java.io.*;
import com.sun.rowset.*;

class ReadChache
{
public static void main(String[] args) throws Exception
{
FileInputStream fis=new FileInputStream("D:\\cached.txt");

ObjectInputStream ois=new ObjectInputStream(fis);

CachedRowSetImpl cr=(CachedRowSetImpl)ois.readObject();

while(cr.next())
{
System.out.println(cr.getInt(1)+"\t"+cr.getString(2)+cr.getString(3));
}
}
}

Thursday, 16 June 2016

JDBC PROGRAM TO WORKING WITH WEBROWSET

import javax.sql.*;
import javax.sql.rowset.*;
import java.io.*;
import com.sun.rowset.WebRowSetImpl;

class WebRowSetExample
{
public static void main(String[] args) throws Exception
{
WebRowSet wrs=new WebRowSetImpl();

Class.forName("oracle.jdbc.driver.OracleDriver");

wrs.setCommand("select * from registration");
wrs.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
wrs.setUsername("cloud");
wrs.setPassword("cloud");
wrs.execute();

FileWriter fw=new FileWriter("D:\\oracle.xml");

wrs.writeXml(fw);
}
}