Hi all,
I get 'Invalid string or buffer length' exception when trying to
do this.
String s=resultSet.GetString(1)
Exception:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3906)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5697)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:353)
at sun.jdbc.odbc.JdbcOdbcConnection.buildTypeInfo(JdbcOdbcConnection.java:1503)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:381)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at Controll.Test.sselect(Test.java:72)
at Controll.Test.main(Test.java:33)
Not only getString(), any method in Resulset cannot be assigned to a variable.
But this prints the values. When i try to assign the value to a variable it throws the exception.
System.out.println(resultSet.GetString(1))
Here is my code
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:abc");
Statement stmt = conn.createStatement();
ResultSet rss = stmt.executeQuery("Select * from TimeTrans where PID=100");
while (rss.next())
{
String s=rss.getString(1);//this lines is the problem
// System.out.println(rss.getString(1) );
}
} catch (Exception e) {
e.printStackTrace();
}
Second column of my table is a type of varchar(10)
plz plz....help me.
Im stuck here for 2 days.