Menu
Category

Java

java.sql.SQLException: Protocol violation

Exception in thread “main” java.sql.SQLException: Protocol violation: [1]                 at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:502)                 at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)                 at oracle.jdbc.driver.T4C7Ocommoncall.doOLOGOFF(T4C7Ocommoncall.java:64)                 at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:576)                 at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:5222)                at XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Connection con=createConnection(); Con.close(); Con.commit(); Con.close();   Here, commit() is invoked after the connection is closed, hence the above exception occurred.

java.lang.ArrayIndexOutOfBoundsException while executing batch Statements in Java

I have created a PreparedStatement to execute a batch of insert statements. But while executing, the below exception occurred.java.lang.ArrayIndexOutOfBoundsException: 22 at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow(T4CNumberAccessor.java:207) at oracle.jdbc.driver.T4C8Oall.readRXD(T4C8Oall.java:745) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:371) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115) at oracle.jdbc.driver.OraclePreparedStatement.executeForRowsWithTimeout(OraclePreparedStatement.java:13106) at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:13246) at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:248) at XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  Solution:   After googling, I realized that the PreparedStatement is not accepting more than 6 parameters. Below is…

Using excel file as DB and read data from Java

Java, SQL By May 14, 2014 No Comments

We can use an excel file as a data base. Using java we can create connection to excel file and execute sql query as we do with database. Use the below code to use excel file as a DB and read data from it using java. String stExcelFile=”c:\temp\test.xls”; String stSheetName=”Sheet1”; Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);         Connection conExcel = DriverManager.getConnection(“jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=” +…

java.lang.UnsupportedOperationException

As the name implies when the requested operation is not supported, we get this error. Below is a sample program to generate this error.   public static void main(String args[]){String st[]={“Hi”,”Hello”,”Bye”};List list=Arrays.asList(st);list.add(“Anand”); //Get error at this line System.out.println(” List: “+list);}    If we run this method, we get the below error because we are trying to add a new element to…

Changing End point address of web service in ADF

  Below code explains how to change the web service end point through program.  ServiceRequestService serviceRequestService = new ServiceRequestService(); ServiceRequestPortType serviceRequestPortType = serviceRequestService.getServiceRequestPortType();  BindingProvider bp = (BindingProvider)serviceRequestPortType;            bp.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, “http://localhost:9950/soa-infra/services/default/sr_v2/ServiceRequest.service”);  Here is the explanation for this code. Get port object of the web service Type cast the port object to BindingProvider object  BindingProvider class provides a member method getRequestContext() which…

Hi, Welcome here.
JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.