Click here to Skip to main content
15,897,891 members
Home / Discussions / Java
   

Java

 
GeneralPlease read carefully forum guidelines before posting... Pin
CPallini7-Jun-09 21:13
mveCPallini7-Jun-09 21:13 
GeneralRe: URGENT need a program in java Pin
Nagy Vilmos8-Jun-09 2:03
professionalNagy Vilmos8-Jun-09 2:03 
GeneralRe: URGENT need a program in java Pin
rajisweety11-Jun-09 15:49
rajisweety11-Jun-09 15:49 
GeneralRe: URGENT need a program in java Pin
Java John11-Jun-09 1:56
Java John11-Jun-09 1:56 
Question[Message Deleted] Pin
rajisweety7-Jun-09 7:45
rajisweety7-Jun-09 7:45 
AnswerInappropriate Title Pin
fly9047-Jun-09 10:32
fly9047-Jun-09 10:32 
GeneralI am getting the error when I try to execute a Query. Error retrieving data:1 java.sql.SQLException: [Macromedia][Oracle JDBC Driver]Value can not be converted to requested type.Exception in DBAccessor:formatResults java.sql.SQLException: [Macromedia Pin
ummadu5-Jun-09 10:40
ummadu5-Jun-09 10:40 
GeneralI am getting the error when I try to execute a Query. Error retrieving data:1 java.sql.SQLException: [Macromedia][Oracle JDBC Driver]Value can not be converted to requested type.Exception in DBAccessor:formatResults java.sql.SQLException: [Macromedia Pin
ummadu5-Jun-09 10:40
ummadu5-Jun-09 10:40 
The Query that I am executing is below:
select PRIMARY_KEY from NASTI_AUDIT_FIELD_LKUP nafl,NASTI_AUDIT na WHERE 0 = 0 AND nafl.DESIGNATED_UPDT_SCREEN_NAME = 'NPA-NXX-X MDN Range' AND nafl.FIELD_NAME = 'Category Code' and nafl.NASTI_AUDIT_FIELD_LKUP_ID = na.NASTI_AUDIT_FIELD_LKUP_ID

I have a method formatResults()in the DBAccessor.java file. The above query returns a value of PRIMARY_KEY = 9893834000 and getColumnType of ResultSetMetaData gives me the Integer instead of Numeric. Hence it's trying to cast as Integer and throwing an exception. But my question is why it's returning the type as Integer instead of Numeric. The above query works fine in TOAD. In the database the datatype of this field is NUMERIC. Can any one please help me to figure it out the issue?


private Vector formatResults(ResultSet results, boolean getDateAsString) throws OICException
{
m_logger.debug("Entered into formatResults()" );
Vector rowInfo = new Vector();

try
{
ResultSetMetaData rsmd = results.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 0;
DateFormat formatShort = DateFormat.getDateInstance(DateFormat.SHORT);

while (results.next())
{
Hashtable rowVals = new Hashtable();
for (int i=1; i <= numberOfColumns; ++i)
{
String colName = rsmd.getColumnName(i);
m_logger.debug("colName : " + colName);
int resultType = rsmd.getColumnType(i);
m_logger.debug("resultType : " + resultType);
Object colValue;
if(results.getObject(i) != null)
{
m_logger.debug("results.getObject(i) : " + results.getObject(i));
switch(resultType)
{
case Types.DOUBLE:
case Types.INTEGER:
m_logger.debug("I am in INTEGER");
m_logger.debug("results.getInt(i) : " + results.getInt(i));
colValue = new Integer(results.getInt(i));
m_logger.debug("colValue : " + colValue);
break;
case Types.DECIMAL:
m_logger.debug("I am in DECIMAL");
colValue = new Integer(results.getInt(i));
m_logger.debug("colValue : " + colValue);
break;
case Types.FLOAT:
m_logger.debug("I am in FLOAT");
colValue = new Float(results.getFloat(i));
m_logger.debug("colValue : " + colValue);
break;
case Types.NUMERIC:
m_logger.debug("I am in NUMERIC");
m_logger.debug("results.getLong(i) : " + results.getLong(i));
colValue = new Long(results.getLong(i));
m_logger.debug("colValue : " + colValue);
break;
case Types.TIMESTAMP:
m_logger.debug("I am in TIMESTAMP");
if (getDateAsString)
colValue = formatShort.format(results.getDate(i));
else
colValue = results.getDate(i);
break;
case Types.CLOB:
m_logger.debug("I am in CLOB");
Clob tempClob = results.getClob(i);
colValue = tempClob.getSubString(1,(int)(tempClob.length()));
break;

default:
m_logger.debug("I am in default");
colValue = results.getString(i);
m_logger.debug("colValue : " + colValue);
break;
}
}
else
{
colValue = "";
}

if (colValue != null)
{
rowVals.put(colName, colValue);
}
}
rowInfo.insertElementAt(rowVals, rowCount);
++rowCount;
}
}
catch(SQLException e)
{
e.printStackTrace(System.out);
throw new OICException(e, e.toString() + "Exception in DBAccessor:formatResults \n");
}
return rowInfo;
}
GeneralError getting column type Pin
fly9047-Jun-09 10:41
fly9047-Jun-09 10:41 
Questionclient server communication Pin
dumnbncool5-Jun-09 7:21
dumnbncool5-Jun-09 7:21 
QuestionBackground dimmer Pin
EnchantedSun5-Jun-09 3:56
EnchantedSun5-Jun-09 3:56 
QuestionProblem with JSObject Pin
raesa5-Jun-09 2:44
raesa5-Jun-09 2:44 
QuestionJava Swing - Right Click and JPopupMenu in JTable Pin
djDash5-Jun-09 0:25
djDash5-Jun-09 0:25 
QuestionRe: Java Swing - Right Click and JPopupMenu in JTable Pin
Java John11-Jun-09 1:59
Java John11-Jun-09 1:59 
QuestionCreating a file and saving it on a networked computer [modified] Pin
ItIsFinished4-Jun-09 12:00
ItIsFinished4-Jun-09 12:00 
AnswerRe: Creating a file and saving it on a networked computer [modified] Pin
darkdragn5-Jun-09 2:45
darkdragn5-Jun-09 2:45 
GeneralRe: Creating a file and saving it on a networked computer Pin
ItIsFinished5-Jun-09 5:44
ItIsFinished5-Jun-09 5:44 
QuestionWriting a simple HTML report using Java Pin
raesa3-Jun-09 20:15
raesa3-Jun-09 20:15 
AnswerRe: Writing a simple HTML report using Java Pin
Ali Shakiba10-Jun-09 22:19
Ali Shakiba10-Jun-09 22:19 
Questionneed help geeting a nullpointerexeption [modified] Pin
ashish_bhatia3-Jun-09 1:07
ashish_bhatia3-Jun-09 1:07 
AnswerRe: need help geeting a nullpointerexeption Pin
Nagy Vilmos3-Jun-09 2:00
professionalNagy Vilmos3-Jun-09 2:00 
RantRe: need help geeting a nullpointerexeption [modified] Pin
ItIsFinished4-Jun-09 12:13
ItIsFinished4-Jun-09 12:13 
GeneralRe: need help geeting a nullpointerexeption Pin
Nagy Vilmos5-Jun-09 3:46
professionalNagy Vilmos5-Jun-09 3:46 
QuestionMobile Application Pin
cdpace2-Jun-09 23:40
cdpace2-Jun-09 23:40 
AnswerRe: Mobile Application Pin
Nagy Vilmos3-Jun-09 0:08
professionalNagy Vilmos3-Jun-09 0:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.