当前位置: 首页>>代码示例>>Java>>正文


Java RowSetProvider类代码示例

本文整理汇总了Java中javax.sql.rowset.RowSetProvider的典型用法代码示例。如果您正苦于以下问题:Java RowSetProvider类的具体用法?Java RowSetProvider怎么用?Java RowSetProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RowSetProvider类属于javax.sql.rowset包,在下文中一共展示了RowSetProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RowSetValues

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@DataProvider(name = "RowSetValues")
private Object[][] RowSetValues() throws SQLException {
    RowSetFactory rsf = RowSetProvider.newFactory();
    RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
    return new Object[][]{
        {rsf, DEFAULT_CACHEDROWSET_CLASSNAME},
        {rsf, DEFAULT_FILTEREDROWSET_CLASSNAME},
        {rsf, DEFAULT_JDBCROWSET_CLASSNAME},
        {rsf, DEFAULT_JOINROWSET_CLASSNAME},
        {rsf, DEFAULT_WEBROWSET_CLASSNAME},
        {rsf1, STUB_CACHEDROWSET_CLASSNAME},
        {rsf1, STUB_FILTEREDROWSET_CLASSNAME},
        {rsf1, STUB_JDBCROWSET_CLASSNAME},
        {rsf1, STUB_JOINROWSET_CLASSNAME},
        {rsf1, STUB_WEBROWSET_CLASSNAME}

    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:RowSetFactoryTests.java

示例2: getData

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public CachedRowSet getData(String statement, List<String> arguments, String preferredDS) throws SQLException {
	CachedRowSet data = null;
	ResultSet rs = null;
	Connection conn = null;
	try {
		data = RowSetProvider.newFactory().createCachedRowSet();
		conn = getConnection();
		PreparedStatement ps = conn.prepareStatement(statement);
		if(arguments != null) {
			for (int i = 0; i < arguments.size(); i++) {
				ps.setObject(i+1, arguments.get(i));
			}
		}
		rs = ps.executeQuery();
		data.populate(rs);
	} catch (Throwable exc) {
		throw (SQLException)exc;
	} finally {
		if (conn != null)
			conns.add(conn);
	}
	return data;
}
 
开发者ID:att,项目名称:music,代码行数:24,代码来源:DBResourceManager.java

示例3: main

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public static void main(String[] args) throws SQLException {

        try {
            JdbcRowSet rowSet = RowSetProvider.newFactory().createJdbcRowSet();
            rowSet.setUrl(URL + DB_NAME);
            rowSet.setPassword(PASSWORD);
            rowSet.setUsername(USER_NAME);
            rowSet.setCommand("SELECT * FROM customers WHERE sex = ?");
            rowSet.setString(1, "male");
            rowSet.execute();
            while (rowSet.next()) {
                System.out.println(rowSet.getRow() + " " + rowSet.getString(2));
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:zaleslaw,项目名称:JDBC_Tutorial,代码行数:19,代码来源:Ex_17_RowSetSelect.java

示例4: execute

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@Override
public IResult execute(IProgressListener listener) throws Exception {
	Connection con = null;
	Statement st = null;
	ResultSet rs = null;

	try {
		con = OptiqDataSource.getConnection(snapshot);

		st = con.createStatement();
		rs = st.executeQuery(sql);

		RowSetFactory rowSetFactory = RowSetProvider.newFactory();
		CachedRowSet rowSet = rowSetFactory.createCachedRowSet();
		rowSet.populate(rs);

		return new RowSetTable(rowSet);
	} finally {
		OptiqDataSource.close(rs, st, con);
	}
}
 
开发者ID:vlsi,项目名称:optiq-mat-plugin,代码行数:22,代码来源:Query.java

示例5: fillWithQuery

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
private void fillWithQuery(String query) {
    try {
        RowSetFactory rowSetFactory = RowSetProvider.newFactory();
        dataModel = rowSetFactory.createJdbcRowSet();
        dataModel.setUrl(conn.getMetaData().getURL());
        dataModel.setUsername(conn.getMetaData().getUserName());
        dataModel.setPassword("");

        dataModel.setCommand(query);
        dataModel.execute();

        columnsMetaData = dataModel.getMetaData();

        fireTableDataChanged();

    } catch (SQLException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:20,代码来源:JDBCSheet.java

示例6: main

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public static void main(String[] args) throws SQLException {
    Connection conn = CreateH2Database.createSimpleDatabase("~/test", true, true);

    RowSetFactory rowSetFactory = RowSetProvider.newFactory();
    JdbcRowSet dataModel = rowSetFactory.createJdbcRowSet();
    dataModel.setUrl(conn.getMetaData().getURL());
    dataModel.setUsername(conn.getMetaData().getUserName());
    dataModel.setPassword("");

    dataModel.setCommand("select * from test_table");
    dataModel.execute();

    // now update the database
    dataModel.absolute(1);
    dataModel.setString(2, "Hello world 2");

    // This throws an exception but according to
    // http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html#updating-column-value
    // it shouldn't
    try {
        dataModel.updateRow();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    conn.close();
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:27,代码来源:UpdateRowSet.java

示例7: main

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public static void main(String args[])
{
   // connect to database books and query database
   try (JdbcRowSet rowSet =
      RowSetProvider.newFactory().createJdbcRowSet())
   {
      // specify JdbcRowSet properties 
      rowSet.setUrl(DATABASE_URL);        
      rowSet.setUsername(USERNAME);          
      rowSet.setPassword(PASSWORD);          
      rowSet.setCommand("SELECT * FROM authors"); // set query
      rowSet.execute(); // execute query                        

      // process query results
      ResultSetMetaData metaData = rowSet.getMetaData();
      int numberOfColumns = metaData.getColumnCount();
      System.out.println("Authors Table of Books Database:\n");

      // display rowset header
      for (int i = 1; i <= numberOfColumns; i++)
         System.out.printf("%-8s\t", metaData.getColumnName(i));
      System.out.println();
      
      // display each row
      while (rowSet.next()) 
      {
         for (int i = 1; i <= numberOfColumns; i++)
            System.out.printf("%-8s\t", rowSet.getObject(i));
         System.out.println();
      }
   }
   catch (SQLException sqlException) 
   {
      sqlException.printStackTrace();
      System.exit(1);
   }
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:38,代码来源:JdbcRowSetTest.java

示例8: StandardCachedRowSetFactory

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public StandardCachedRowSetFactory() {
	try {
		this.rowSetFactory = RowSetProvider.newFactory();
	}
	catch (SQLException ex) {
		throw new IllegalStateException("Cannot create RowSetFactory through RowSetProvider", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SqlRowSetResultSetExtractor.java

示例9: CommonRowSetTests

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public CommonRowSetTests() {
    try {
        rsf = RowSetProvider.newFactory();
    } catch (SQLException ex) {
        Assert.fail(ex.getMessage());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:CommonRowSetTests.java

示例10: test04

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@Test
public void test04() throws Exception {
    File f = new File(jarPath + "goodFactory");
    URLClassLoader loader = new URLClassLoader(new URL[]{
        new URL(f.toURI().toString())}, getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(loader);
    validateProvider(RowSetProvider.newFactory(), STUB_FACTORY_CLASSNAME);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:RowSetProviderTests.java

示例11: test05

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@Test(expectedExceptions = SQLException.class)
public void test05() throws Exception {
    File f = new File(jarPath + "badFactory");
    URLClassLoader loader = new URLClassLoader(new URL[]{
        new URL(f.toURI().toString())}, getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(loader);
    RowSetProvider.newFactory();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:RowSetProviderTests.java

示例12: RowSetFactoryValues

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@DataProvider(name = "RowSetFactoryValues")
private Object[][] RowSetFactoryValues() throws SQLException {
    RowSetFactory rsf = RowSetProvider.newFactory();
    RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
    RowSetFactory rsf2 = RowSetProvider.newFactory(DEFFAULT_FACTORY_CLASSNAME, null);
    return new Object[][]{
        {rsf, NO_VALADATE_IMPL},
        {rsf, DEFFAULT_FACTORY_CLASSNAME},
        {rsf1, STUB_FACTORY_CLASSNAME},
        {rsf2, DEFFAULT_FACTORY_CLASSNAME}
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:RowSetProviderTests.java

示例13: runPreparedStatement

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
private CachedRowSet runPreparedStatement(String query,
		List<Object> parameters, Connection connection) throws SQLException {
	PreparedStatement preparedStatement = null;
	try {
		preparedStatement = connection.prepareStatement(query);
		if (parameters != null) {
			int paramCount = 1;
			for (Object parameter : parameters) {
				@SuppressWarnings("rawtypes")
				Class<? extends Object> type = parameter.getClass();
				if (type.equals(String.class)) {
					preparedStatement.setString(paramCount,
							(String) parameter);
				}
				if (type.equals(Integer.class)) {
					preparedStatement.setInt(paramCount,
							(Integer) parameter);
				}
				paramCount++;
			}

		}
		if (query.toLowerCase().startsWith("select")) {
			ResultSet result = preparedStatement.executeQuery();
			CachedRowSet rowSet = RowSetProvider.newFactory()
					.createCachedRowSet();
			rowSet.populate(result);
			log.debug("prepareAndExecuteStatement:return result");
			return rowSet;
		} else {
			preparedStatement.execute();
			log.debug("prepareAndExecuteStatement:return null");
			return null;
		}
	} finally {
		if (preparedStatement != null) {
			preparedStatement.close();
		}
	}
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:41,代码来源:DatabaseServiceImpl.java

示例14: main

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    RowSet rs;

    RowSetFactory rsFactory = RowSetProvider.newFactory();
    rs = rsFactory.createCachedRowSet();

    rs.setUrl("jdbc:postgresql:tmclub");
    rs.setUsername("ian");
    rs.setPassword("secret");

    rs.setCommand("select * from members where name like ?");
    rs.setString(1, "I%");

    // This will cause the RowSet to connect, fetch its data, and
    // disconnect
    rs.execute();

    // Some time later, the client tries to do something.

    // Suppose we want to update data:
    while (rs.next()) {
        if (rs.getInt("id") == 42) {
            rs.setString(1, "Marvin");
            rs.updateRow();    // Normal JDBC

            // This additional call tells the CachedRowSet to connect
            // to its database and send the updated data back.
            rs.updateRow();
        }
    }

    // If we're all done...
    rs.close();
}
 
开发者ID:shashanksingh28,项目名称:code-similarity,代码行数:35,代码来源:CachedRowSetDemo.java

示例15: test01

import javax.sql.rowset.RowSetProvider; //导入依赖的package包/类
@Test
public void test01() throws SQLException {
    System.setProperty("javax.sql.rowset.RowSetFactory",
            DEFFAULT_FACTORY_CLASSNAME);
    validateProvider(RowSetProvider.newFactory(), DEFFAULT_FACTORY_CLASSNAME);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:RowSetProviderTests.java


注:本文中的javax.sql.rowset.RowSetProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。