I just started IPv6 testing and hit the error below. I am not sure what it's all about, but will investingate more thoroughly and get a Jira filed this afternoon.

66 java org.apache.derby.drda.NetworkServerControl start -h 2002:92a:8f7a:13
:9:42:73:216&
   67  java DataSourceTest


Exception in thread "main" java.sql.SQLNonTransientConnectionException: Network protocol exception: actual code point, 4,692, does not match expected code point
, 9,224.  The connection has been terminated.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unkn
own Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Sourc
e)
at org.apache.derby.client.am.Statement.executeUpdate(Unknown Source)
        at DataSourceTest.GrantRevokeTest(DataSourceTest.java:46)
        at DataSourceTest.main(DataSourceTest.java:25)
Caused by: org.apache.derby.client.am.DisconnectException: Network protocol exce ption: actual code point, 4,692, does not match expected code point, 9,224. The
 connection has been terminated.
at org.apache.derby.client.net.Reply.parseLengthAndMatchCodePoint(Unknow
n Source)
at org.apache.derby.client.net.NetConnectionReply.parseSQLCARD(Unknown S
ource)
at org.apache.derby.client.net.NetConnectionReply.parseRDBCMMreply(Unkno
wn Source)
at org.apache.derby.client.net.NetConnectionReply.readLocalCommit(Unknow
n Source)
at org.apache.derby.client.net.ConnectionReply.readLocalCommit(Unknown S
ource)
at org.apache.derby.client.net.NetConnection.readLocalCommit_(Unknown So
urce)
        at org.apache.derby.client.am.Connection.readCommit(Unknown Source)
at org.apache.derby.client.am.Connection.readAutoCommit(Unknown Source)
        at org.apache.derby.client.am.Statement.flowExecute(Unknown Source)
at org.apache.derby.client.am.Statement.executeUpdateX(Unknown Source)
        ... 3 more


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;

import org.apache.derby.jdbc.EmbeddedDataSource;
import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
import org.apache.derby.jdbc.EmbeddedXADataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.SQLException;
import javax.sql.DataSource;

public class DataSourceTest{
    public static void main(String[] args) throws Exception {
        javax.sql.DataSource ds = getDS("mydb;create=true", null, null);
        Connection conn = ds.getConnection("user2", "pass2");
        //DropTables(conn);
        GrantRevokeTest(conn);
        TestPStmt(conn);
        TestClob(conn);
        TestBlob(conn);
        TestClobBlob(conn);
        TestFunction(conn);

    }
    public static void DropTables(Connection conn) throws Exception{
        Statement stmt = conn.createStatement();
        stmt.executeUpdate("drop table tab2");
        stmt.executeUpdate("drop table tabclob");
        stmt.executeUpdate("drop table tabblob");
        stmt.executeUpdate("drop table tabclobblob");
        stmt.executeUpdate("drop function f_abs");
        stmt.executeUpdate("drop table tabfunction");
        stmt.close();
    }

    public static void GrantRevokeTest(Connection conn) throws Exception{
        Statement stmt = conn.createStatement();
        stmt.executeUpdate("create table tab2(c1 int, c2 char(3))");
        stmt.executeUpdate("grant select on tab2 to public");
ResultSet rs = stmt.executeQuery("select GRANTEE, GRANTOR, SELECTPRIV, DELETEPRIV, INSERTPRIV, UPDATEPRIV, REFERENCESPRIV, TRIGGERPRIV from sys.systableperms");
        while(rs.next())
        {
System.out.println("Gtrantee in the systableperms : " + rs.getString(1));
        }
        stmt.executeUpdate("grant select on tab2 to public");
        stmt.close();
        rs.close();
        System.out.println("GrantRevokeTest Passed");
    }

    public static void TestPStmt(Connection conn) throws Exception{
PreparedStatement ps = conn.prepareStatement("insert into tab2 values(?,?)");
        Statement stmt = conn.createStatement();
        for(int i=0;i<10;i++){
            ps.setInt(1,i);
            ps.setString(2,"aa" +i);
            ps.executeUpdate();
            }
            ResultSet rs = stmt.executeQuery("select * from tab2");
            while(rs.next())
                System.out.println("Col1: "+rs.getInt(1));
            stmt.close();
            ps.close();
            rs.close();
            System.out.println("TestPStmt Passed");
    }

    public static void TestClob(Connection conn) throws Exception{
        String insertRow = "insert into tabclob values(?,?)";
        String ss= "create table tabclob(a int, b clob(3M))";
        Statement stmt = conn.createStatement();
        stmt.executeUpdate(ss);
        PreparedStatement Insert = conn.prepareStatement(insertRow);
        Insert.setInt(1,1);
        try {
            File inputfile = new File("l1.txt");
            FileReader fr = new FileReader(inputfile);
            BufferedReader br = new BufferedReader(fr);
            Insert.setCharacterStream(2, fr, (int) inputfile
                                .length());
            } catch (FileNotFoundException e) {
System.out.println("File not found Exception : " + e.getMessage());
                throw e;
                }
        int rows = Insert.executeUpdate();
        System.out.println("Rows inserted: " + rows);
        stmt.close();
        Insert.close();
        System.out.println("TestClob passed");

    }
    public static void TestBlob(Connection conn) throws Exception{
        String insertRow = "insert into tabblob values(?,?)";
        String ss= "create table tabblob(a int, b blob(3M))";
        Statement stmt = conn.createStatement();
        stmt.executeUpdate(ss);
        PreparedStatement Insert = conn.prepareStatement(insertRow);
        Insert.setInt(1,1);
        try{
            File inputfile = new File("p1.jpg");
            InputStream fileIn = new FileInputStream(inputfile);
            Insert.setBinaryStream(2, fileIn, (int) inputfile.length());
        }catch (FileNotFoundException e) {
System.out.println("File not found Exception : " + e.getMessage());
            throw e;
            }
        int rows = Insert.executeUpdate();
        System.out.println("Rows inserted: " + rows);
        stmt.close();
        Insert.close();
        System.out.println("TestBlob passed");

}

public static void TestClobBlob(Connection conn) throws Exception{

            String insertRow = "insert into tabclobblob values(?,?)";
            String ss= "create table tabclobblob(a clob(3M), b blob(3M))";
            Statement stmt = conn.createStatement();
            stmt.executeUpdate(ss);
            PreparedStatement Insert = conn.prepareStatement(insertRow);
            ResultSet rs = stmt.executeQuery("select a, b from tabBlob");
            Blob blob = null;
            Clob clob = null;
            while (rs.next())
                blob = rs.getBlob(2);
            if (blob != null)
               Insert.setBlob(2,blob);
            rs = stmt.executeQuery("select a, b from tabclob");
            while (rs.next())
                clob = rs.getClob(2);
            if (clob != null)
                   Insert.setClob(1,clob);
               int rows = Insert.executeUpdate();
            System.out.println("Rows inserted: " + rows);
             rs.close();
             stmt.close();
             Insert.close();
             System.out.println("TestClobBlob Passed");

}

public static void TestFunction(Connection conn)throws Exception{
    Statement stmt = conn.createStatement();
    int result = stmt.executeUpdate(
                "CREATE FUNCTION F_ABS(P1 INT) RETURNS INT NO "
                + "SQL RETURNS NULL ON NULL INPUT EXTERNAL NAME "
            + "'java.lang.Math.abs' LANGUAGE JAVA PARAMETER STYLE JAVA");
    int abs = 0;
    ResultSet rs = stmt.executeQuery(" values f_abs(-5)");
    while(rs.next())
        abs = rs.getInt(1);
    System.out.println("abs value: " + abs);
    String insertRow = "insert into tabfunction values(?,?)";
    String ss= "create table tabfunction(a int, b int)";
    //Statement stmt = conn.createStatement();
    stmt.executeUpdate(ss);
    PreparedStatement Insert = conn.prepareStatement(insertRow);
    Insert.setInt(1,1);
    Insert.setInt(2,abs);
    int rows = Insert.executeUpdate();
    System.out.println("Rows inserted: " + rows);
    Insert.close();
    stmt.close();
    rs.close();
    System.out.println("TestFunction Passed");

}

public static javax.sql.DataSource getDS(String database, String user, String
password) throws SQLException
{
org.apache.derby.jdbc.ClientDataSource ds =
   new org.apache.derby.jdbc.ClientDataSource();

// DatabaseName can include Derby URL Attributes
ds.setDatabaseName(database);

if (user != null)
   ds.setUser(user);
if (password != null)
   ds.setPassword(password);

// The host on which Network Server is running
//edit this to the name of the server(IPV6) you are using
ds.setServerName("wicopt1-v6.rtp.raleigh.ibm.com");

// port on which Network Server is listening
ds.setPortNumber(1527);

return ds;
}

}




Reply via email to