Best code examples for Java 8 ResultSetMetaData class (java.sql.ResultSetMetaData)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ResultSetMetaData class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 ResultSetMetaData examples from Open Source projects
This code example shows how to use the following methods: isWritable
     * fail, Failing statements commented out. Feature only partially 
     * implemented. 
     */ 
    public void testIsWritable() { 
        try { 
            assertTrue(rsmd.isWritable(1));
            assertTrue(rsmd.isWritable(2));
            assertTrue(rsmd.isWritable(3));
        } catch (SQLException e1) {
            fail("ResultSetMetaDataTest.isWritable" + e1.getMessage());
            e1.printStackTrace();
        } 
 
        // Exception testing 
 
        try { 
            rsmd.isWritable(0);
            fail("SQLException is not thrown"); 
        } catch (SQLException e) {
            // expected 

7
CodeRank
This code example shows how to use the following methods: getColumnCount
 
		expect(connection.getUnderlyingConnection()).andReturn(sqlConnection).anyTimes();
		expect( sqlConnection.createStatement()).andReturn(statement);
		expect( statement.executeQuery("SELECT CONVERT(varchar(100), SERVERPROPERTY('COLLATION'))")).andReturn(resultSet);
		expect( resultSet.next() ).andReturn(true);
		expect( resultSet.getMetaData() ).andReturn(metadata);
		expect( metadata.getColumnCount() ).andReturn(1);
		expect( resultSet.getString(1)).andReturn(collation);
		expect( resultSet.next() ).andReturn(false);
 
		connection.attached(database);
		replay(connection, sqlConnection, statement, resultSet, metadata);
		database.setConnection(connection);
		return database;
    } 
     
    @Test
    public void caseSensitiveBinaryCollation() throws Exception {
    	Database database =  getADatabaseWithCollation("Latin1_General_BIN");
    	assertTrue( "Should be case sensitive", database.isCaseSensitive() );
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getColumnName, getColumnType
     */ 
    public void process(Table t, int trow, ResultSet rset, int rcol)
        throws SQLException 
    { 
        ResultSetMetaData metadata = rset.getMetaData();
        String field = metadata.getColumnName(rcol);
        int type = metadata.getColumnType(rcol);
         
        switch ( type ) {
        case Types.ARRAY:
            t.set(trow, field, rset.getArray(rcol));
            break; 
             
        case Types.BIGINT:
            t.setLong(trow, field, rset.getLong(rcol));
            break; 
             
        case Types.BINARY:
        case Types.LONGVARBINARY:
        case Types.VARBINARY:
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCatalogName, getColumnClassName, getColumnName, getColumnType, getColumnTypeName
This code example shows how to use the following methods: getColumnClassName
        } 
    } 
 
    public void testGetColumnClassName() { 
        try { 
            assertNotNull(rsmd);
            assertEquals(Short.class.getName(), rsmd.getColumnClassName(1));
            assertEquals(String.class.getName(), rsmd.getColumnClassName(2));
            assertEquals(String.class.getName(), rsmd.getColumnClassName(3));
        } catch (SQLException e) {
            fail("SQLException is thrown: " + e.getMessage());
        } 
 
        try { 
            String name  = rsmd.getColumnClassName(0);
            assertNull(name);
        } catch (SQLException e) {
            fail("SQLException is thrown"); 
        } 
 

7
CodeRank
Related Java 8 ResultSetMetaData Questions & Answers:
See Code Examples for Java 8 ResultSetMetaData Methods: