JDBC RowSet DML Sample

Hello,
Excuses for school English + google,
With javac : error: AirlinesDML.java:42: unreported exception java.sql.SQLException; must be caught or declared to be thrown private static RowSet rowset = new OracleJDBCRowSet();
With Java version "1.5.0_06".
I am deroute because the throws SQLException east declares in the code!
If a person can m help that would be sympathetic nerve.
Thank,
Claude

Sorry, the source :
package oracle.otnsamples.jdbc;
import javax.sql.RowSet;
import oracle.jdbc.rowset.OracleJDBCRowSet;
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.sql.SQLException;
public class AirlinesDML {
private static RowSet rowset = new OracleJDBCRowSet(); // ERROR
protected RowSetCache rowSetCache;
public AirlinesDML() {
public List selectRecords(String code,String name, String partner)
throws SQLException, IOException{
String query = null;
ArrayList data = new ArrayList( );
try {      
code = "%"+code+"%";
name = "%"+name+"%";
partner = "%"+partner+"%";
query = "SELECT * FROM otn_airlines " +
"WHERE UPPER(code) LIKE UPPER('"+code+"') AND " +
"UPPER(name) LIKE UPPER('"+name+"') AND " +
"UPPER(partner) LIKE UPPER('"+partner+"') ORDER BY code";
rowset = RowSetCache.getInstance().getRowSet();
rowset.setCommand (query);
rowset.execute ();
while (rowset.next ()) {        
String[] row = new String[3];
for ( int i = 0; i < 3; i++ ) {
row[ i ] = rowset.getString( i + 1 );
data.add(row);
} finally {      
rowset.close();
return data;
public void insertRecord( String code,String name,String partner )
throws SQLException, IOException{
String query = null;
try {     
query = "INSERT INTO otn_airlines VALUES ('"+code+"','"+name+"','"+
partner+"')";
rowset = RowSetCache.getInstance().getRowSet();
rowset.setCommand (query);
rowset.execute();
} finally {      
rowset.close();
public void updateRecord(String code, String name, String partner)
throws SQLException, IOException{
String query = null;
try {    
query = "SELECT * FROM otn_airlines " +
"WHERE UPPER(code) LIKE UPPER('"+code+"')";
rowset = RowSetCache.getInstance().getRowSet();
rowset.setCommand(query);
rowset.execute();
query = "UPDATE otn_airlines SET name ='"+name+"', partner ='"
partner"' WHERE code ='"+code+"'";
rowset.setCommand(query);
rowset.execute();
} finally {  
rowset.close();
public void deleteRecord(String code) throws SQLException, IOException{
String query = null;
try {   
query = "DELETE FROM otn_airlines WHERE code='"+code+"'";
rowset = RowSetCache.getInstance().getRowSet();
rowset.setCommand(query);
rowset.execute();
} finally {      
rowset.close();
public boolean checkTables() throws SQLException, IOException, Exception{
try {        
rowset = RowSetCache.getInstance().getRowSet();
rowset.setCommand (" SELECT table_name FROM user_tables "+
" WHERE table_name = 'OTN_AIRLINES' ");
rowset.execute ();
if (!rowset.next ()) {       
this.createSchemaTables();
} finally {    
rowset.close();
return true;
public void createSchemaTables() throws SQLException, IOException, Exception {
this.createTable();
this.insertRecord("2R", "2R Airways", "N");
this.insertRecord("2S", "2S Airways", "N");
this.insertRecord("3C", "3C Airways", "N");
this.insertRecord("3M", "3M Airways", "N");
this.insertRecord("4S", "4S Airways", "N");
this.insertRecord("5A", "5A Airways", "N");
this.insertRecord("7F", "7F Airways", "N");
this.insertRecord("A3", "A3 Airways", "N");
this.insertRecord("AA", "AA Airways", "N");
this.insertRecord("AC", "AC Airways", "N");
this.insertRecord("AD", "AD Airways", "N");
this.insertRecord("6E", "6E Airways", "N");
public void createTable() throws SQLException, IOException{
try {    
rowset = RowSetCache.getInstance().getRowSet();
String query = "CREATE TABLE otn_airlines(code VARCHAR2(2) NOT NULL " +
"PRIMARY KEY, name VARCHAR2(40) NOT NULL, "+
"partner VARCHAR2(1) NOT NULL)";
rowset.setCommand(query);
rowset.execute();
} finally {     
rowset.close();
}

Similar Messages

  • Sun ONE Studio 5 evaluation. JDBC RowSet question.

    I am accessing a MYSQL database using form wizard. I am also using the DataNavaigator. When I use RowSet type: NB CachedRowSet, I can bring in and scroll through existing data, add, change, and delete rows with no problem. When I use NB JDBC RowSet, I can not do any of these things. I do not receive an error, it just not work. It is my understanding that for larger rowsets, I should be using the JDBC RowSet. Also, when calling in a large row set, how do you get to an item without scrolling to it using the DataNavagator. Thank you in adavance for your time.

    In the Sun One the is a ServerAdministrative menu by clicking on it u get a window to look that deployed application... check out the server cluster.. load balancing and stuffs like that in the same window there is a Database icon where u have to set the driver path and give the drive name.. with the max connection min connection that would solve your problem

  • Package sun.jdbc.rowset does not exist

    Hi,
    I am tryng to use a CachedRowSet in a JSP page. I got rowset.jar from sun and I put it in my classpath. When I try to import sun.jdbc.rowset I have the message "package sun.jdbc.rowset does not exist".
    Please, could someone help me?
    Tanks,
    Celso

    Hi,
    Unfortunately not... The name of the package is rowset...
    Some others ideas? Thanks,
    Celso

  • How to use JDBC RowSet ?

    Dear all,
    I downloaded Jdbc Rowset and configured it in my PC. But when I use CathedRowSet,it give me the following errors.
    Exception in thread "main" java.lang.UnsupportedClassVersionError: javax/sql/Row
    Set (Unsupported major.minor version 48.0)....
    I am using JDK1.4.
    Does anybodu give me an idea ?
    Thank you.
    Kevin

    Have a look at your other thread I posted an answer there.
    These classes were probably compiled with jdk 1.3 so won't work with 1.4. You need to uninstall 1.4 and reinstall with 1.3 to use these classes.
    (the other thread is http://forum.java.sun.com/thread.jsp?forum=4&thread=292105)

  • Problem with sun.jdbc.rowset.CachedRowSet.

    Hi All,
    I cannot not able to import the package 'sun.jdbc.rowset.CachedRowSet'.
    while writing the path in the jsp:useBean or import to java class it shows at the compilation time that
    Error JavaCompile: sun.jdbc.rowset cannot be resolved.
    Is there any jar file needed and if then where i can find it.
    actually i need to import this for implementing the large row in paging system in jsp page.
    Thanks in advance.
    Regards
    ukbasak

    hi,
    Another link which to point over the rowset.jar file
    http://forums.systeminetwork.com/isnetforums/archive/index.php?t-36523.html

  • Exporting table data from a JDBC rowset to an excel sheet

    Hi,
        I am developing an application in which I have to insert and display records on a view.
        I have used a webservice to display data.
        On the display view I need to provide a button which on clicking exports the table data to an excel sheet.
       I want to use the JDBC rowset to export data to an excel rather than the binary cache method.
       So could someone plz help me out with the code.

    Dear Abinas,
    Please read this tutorial.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353?QuickLink=index&…
    Thanks & Regards,
    Patralekha

  • Sun.jdbc.rowset where go i get it n in which JDK version

    i saw some code in this forum regarding pagination where sun.jdbc.rowset is being imported..please help me . i get an error saying that sun.jdbc.rowset not found i am using jdk1.4.

    thanks i got the link from the forum
    You can find it at http://java.sun.com/developer/earlyAccess/jdbc/jdbc-rowset.html

  • Sun.jdbc.rowset

    Hi,
    Any one please tell me where i can get sun.jdbc.rowset package.
    please give me specific URL to download the rowset.jar file
    Thanking you,
    Shajahan

    Hello,
    It's probably this one:
    http://java.sun.com/developer/earlyAccess/jdbc/jdbc-rowset.html
    It may also be available in the jdk1.5.

  • JDBC-ROWSET SUPPORT ORACLE

    DID ANY OF THE ORACLE THIN DRIVER SUPPORTS JAVA-ROWSETS. IF SO FROM WHERE I CAN DOWNLOAD THE DRIVER. I TRYED ROWSETS WITH 8.1.7 ORACLE THIN DRIVER, I COULD NOT IMPLEMENT IT.

    Hi I am using latest driver from oracle site, but the problem is when i fire execute method of cahed rowset i throws error that i mentioned above, if you have any other driver than mail me on [email protected]

  • JDBC RowSet

    Hi,
    After calling moveToInsertRow(), for some reason if I do not insert a record. Do I have to call some other method set the cursor back ?
    Is there any method to do that ... because I am getting exception
    Invalid operation for the current cursor position
    Thanks in advance.

    Hi,
    After calling moveToInsertRow(), for some reason if I do not insert a record. Do I have to call some other method set the cursor back ?
    Is there any method to do that ... because I am getting exception
    Invalid operation for the current cursor position
    Thanks in advance.

  • JDBC 2.0 Sample Files dead links

    Hi,
    The following page contains dead links, some .jar files and sources. http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/jdbc20/jdbc20.html
    Please correct this error.
    Gergely Bekecs

    These links have been repaired; thanks for the heads-up.
    Regards, OTN

  • Help  connection to oracle db using jdbc

    Hi
    I am trying to connect to a oracle database. I am using Oracle 9 and jsdk 1.4.2. but i keep getting the following error and i dont know what iam doing wrong.
    I have put in my classpath where the orcle drivers are. I have also tried puting the drivers in j2sdk/jre/lib folder (files copied nls_charset12.zip,classes12.zip,ojdbc14.jar). My code compiles and runs but the error i get is
    "java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver"
    SAMPLE of my code:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String dataSource = "jdbc:oracle:thin:@devflgdb";
    Connection con = DriverManager.getConnection(dataSource,"babu_s2","babu_s2");

    I am working on the same; here is my servlet code, hope it helps
    private static void loadJDBCDriver ()
    System.out.println ("Loading Database driver...");
    try {
         DriverManager.registerDriver ( new oracle.jdbc.driver.OracleDriver());
    catch (Exception e) {}
    try {
    DriverManager.registerDriver ( new sun.jdbc.odbc.JdbcOdbcDriver() );
    catch (Exception e2) {
    System.err.println ("loadJDBCDriver: " + e2.toString());
    return;
    System.out.println ("Database driver loaded...");
    private static Connection getConnected () {
    System.out.println ("Establishing database connection...");
    String jdbc_url;
    Connection conn;
    try {
    jdbc_url = "jdbc:oracle:thin:@localhost:1521:oracle";
    conn = DriverManager.getConnection (jdbc_url, "scott", "tiger");
    catch (Exception e) {
    try {
    jdbc_url = "jdbc:odbc:BookNook";
    conn = DriverManager.getConnection (jdbc_url);
    catch (SQLException e2) {
    System.err.println ("getConnected: " + e2.toString() );
    return null;
    System.out.println ("Database connection established ...");
    return conn;

  • Create Resultset/Rowset programatically

    How can I create a resultset/rowset programatically from scratch, without connecting to database. Actually I'm designing an N-tier intranet app. The page controller (JSP) has to pass the data of the HTTP request to the buiness tier in a generic form. As our business tier is using resultset for its methods (for efficiency and simplicity we avoided using a pure object oriented business tier whose objects have the state as their fields. Instead we have resultsets of the whole query that has the data of a single business transaction).
    Is it possible to create rowset without database connection? How?

    You can do it using CachedRowSet:
    import java.sql.*;
    import javax.sql.*;
    import sun.jdbc.rowset.*;
    public class RowSetExample
    public static void main(String args[])
    try {
    // create a new rowset and populate it...
    sun.jdbc.rowset.CachedRowSet crs = new sun.jdbc.rowset.CachedRowSet();
    sun.jdbc.rowset.RowSetMetaDataImpl rsmdi = new sun.jdbc.rowset.RowSetMetaDataImpl();
    int colCount = 2;
    rsmdi.setColumnCount(colCount);
    rsmdi.setColumnDisplaySize(1, 5);
    rsmdi.setColumnName(1, "ID");
    rsmdi.setColumnType(1, java.sql.Types.INTEGER);
    rsmdi.setColumnTypeName(1, "INTEGER");
    rsmdi.setTableName(1, "MY_TABLE");
    rsmdi.setAutoIncrement(1, false);
    rsmdi.setSearchable(1, true);
    rsmdi.setColumnDisplaySize(2, 20);
    rsmdi.setColumnName(2, "NAME");
    rsmdi.setColumnType(2, java.sql.Types.VARCHAR);
    rsmdi.setColumnTypeName(1, "VARCHAR");
    rsmdi.setTableName(2, "MY_TABLE");
    rsmdi.setAutoIncrement(2, false);
    rsmdi.setSearchable(2, true);
    crs.setMetaData(rsmdi);
    java.util.Map map = new java.util.HashMap();
    map.put(new Integer(1), "AAA");
    map.put(new Integer(2), "BBB");
    map.put(new Integer(3), "CCC");
    java.util.Iterator iter = map.entrySet().iterator();
    while (iter.hasNext()){
    java.util.Map.Entry entry = (java.util.Map.Entry) iter.next();
    int idx = 0;
    crs.moveToInsertRow();
    crs.updateObject(1, entry.getKey());
    crs.updateObject(2, entry.getValue());
    crs.insertRow();
    crs.moveToCurrentRow();
    crs.beforeFirst();
    while (crs.next()){
    System.out.print(crs.getObject(1));
    System.out.println(": " + crs.getObject(2));
    }catch (SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

  • [Oracle JDBC Driver]Invalid parameter binding(s).

    Hi there
    I am using the OracleCachedRowSet, and it works fine until I tries to update a resultset with a null value. When I call rs.acceptChanges(connection); it results in the following exception.
    Please help if anyone has found a workaround to this problem.
    java.sql.SQLException: [BEA][Oracle JDBC Driver]Invalid parameter binding(s).
    at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
    at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
    at weblogic.jdbc.base.BaseParameters.getParameter(Unknown Source)
    at weblogic.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source)
    at weblogic.jdbc.base.BasePreparedStatement.setObject(Unknown Source)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:268)
    at oracle.jdbc.rowset.OracleCachedRowSetWriter.updateRow(OracleCachedRowSetWriter.java:429)
    at oracle.jdbc.rowset.OracleCachedRowSetWriter.writeData(OracleCachedRowSetWriter.java:534)
    at oracle.jdbc.rowset.OracleCachedRowSet.acceptChanges(OracleCachedRowSet.java:2926)
    at eurostat.Items.updateRS(Items.java:192)
    at eurostat.DBConnectionBean.updateRS(DBConnectionBean.java:94)
    at jsp_servlet.__mainpage._jspService(MainPage.jsp:248)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at com.bea.wlw.netui.pageflow.PageFlowJspFilter.doFilter(PageFlowJspFilter.java:246)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6724)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

    Hi Avi
    Thanks for the suggestion, but I don't thint that is the problem. In other forums I have found people describing the same problem(both with Oracle and Sun's implementation of CachedRowSet). See this link for an example http://bugs.mysql.com/bug.php?id=9831. So I figured that those other people needed to have a solution to the problem, but I can't find it.
    /Thomas

  • Still problems with RowSet Sun implementation

    In a topic I previoulsy posted I shown my inability to make JoinRS work:
    http://forum.java.sun.com/thread.jsp?thread=523969&forum=48&message=2540269
    I was told the new realease, due to be out sometime in June, would have included corrections for my problem.
    Do you have any info about the new realease of Rowset RI by Sun?
    I downloaded JDBC RowSet Implementations 1.0 JWSDP 1.4 Co-Bundle, hoping that would be it, but the RI included in it is still 1.0 (though the jar lib files have different size)
    Please help me with any info you can provide. My university thesis would greatly benefit from it.
    Thank you in advance.

    Yes Neo, sometime in the next two weeks, we will release it.
    There is some formalities to be done as soon as they are done we will be out.
    Please saty tuned. :)

Maybe you are looking for

  • Analyzer 6.5.1.2.01063 Gifs problem

    i have a problem when i put an animated gif in a report, when i want to open the report, show me the following error" An unknown exception ocurred while communicating with the server.; nested exception is:java.lang.NullPointerException"how can i solv

  • Software distribution and Unlimited Strength Jurisdiction Policy Files

    I suppose, I'm NOT allowed to ship the Unlimited Strength Jurisdiction Policy Files (USJPF) with my application, even if living in Germany and not selling abroad, right? So I see 2 possibilities: - Use weaker encryption by default and encourage the u

  • Next FLV won't ever load

    Ok...I have 2 flv files that come from my database that tell the player where the 2 FLV"s are that it needs to play. (videos/geeksquad.flv and videos/geeksquadoffer.flv). The first one is loaded and plays upon result from the database like so... vPla

  • How to display currency values in indian format

    hi all,    When I am displaying Currency values as output , those are displaying in U.S. format (ie.1,234,000.00) , But I need to display those in Indian Rupee format (i.e 12,34,000.00). Plz any one can help me that how to display this thank you, reg

  • How to burn to ISO image in Premiere Elements 12.1 under Windows 8.1 64bit?

    I really struggle - is there no way to burn from PE12.1 to ISO image (under Win 8.1)?