473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java.sql.SQLExc eption

madhoriya22
252 Contributor
Hi,
Here is the query which I am using to get the values from the database:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. "SELECT ?, COUNT(*) AS COUNT " +
  3.             "FROM DEFECT_DETAIL " +
  4.             "WHERE TARGET_MILESTONE = ? " +
  5.             "GROUP BY ?";
  6.  
and here is function throught which I am getting data:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. public Hashtable getTargetMilestoneDefectCount(String varColumn, String targetM) {
  3.         Connection con = null;
  4.         ResultSet rs = null;
  5.         String str = null;
  6.  
  7.         Hashtable defectCountList = new Hashtable();
  8.         try {
  9.              con = new MySqlDAOFactory().getConnection();
  10.             PreparedStatement pStatement = null;
  11.             //passing query to the database
  12.             pStatement = con.prepareStatement( GET_TARGET_MILESTONE_DEFECT_COUNT);
  13.             System.out.println( GET_TARGET_MILESTONE_DEFECT_COUNT);
  14.  
  15.             pStatement.setString(1, varColumn);
  16.             pStatement.setString(2, targetM);
  17.             pStatement.setString(3, varColumn);
  18.  
  19.             rs = pStatement.executeQuery();
  20.             while(rs.next()) {
  21.                 System.out.println("Inside while loop");
  22.  
  23.                 DefectReportVO defectReportVO = new DefectReportVO();
  24.  
  25.                 str = rs.getString(varColumn);
  26.                 defectReportVO.setCount(rs.getInt("COUNT"));
  27.  
  28.                 if(defectReportVO != null) {
  29.                     defectCountList.put(str, defectReportVO);
  30.                 }
  31.             }
  32.             rs.close();//closing result set
  33.             pStatement.close();//closing prepared statement
  34.  
and here is how I am calling this function:-
Expand|Select|Wrap|Line Numbers
  1.  Hashtable statusCountList = distinctReportsDAO.getTargetMilestoneDefectCount("STATUS", "v.1.24.00");
  2.  
Now it is throwing Exception:-
Expand|Select|Wrap|Line Numbers
  1. java.sql.SQLException: Column 'STATUS' not found.
  2.         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
  3.         at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:955)
  4.         at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5436)
  5.         at com.spi.defecttracker.dao.DefectReportDAOImpl.getTargetMilestoneDefectCount(DefectReportDAOImpl.java:846)
  6.         at com.spi.defecttracker.test.testMain.main(testMain.java:52)
  7.  
i am not able to find what is the problem... STATUS column is there in the table...?

thanks and regards,
madhoriya
Aug 22 '07 #1
21 3449
r035198x
13,262 MVP
Looks like the status column is not there alright.
Can you see it if you connect to the database from somewhere else e.g from a console/shell?

P.S Nice avatar
Aug 22 '07 #2
madhoriya22
252 Contributor
P.S Nice avatar
Hi,
Thanks. I had done a lot of hard work in finding that avatar.
note:- size limit provided for the avatar is very small.
Looks like the status column is not there alright.
Can you see it if you connect to the database from somewhere else e.g from a console/shell?
STATUS column is there in the table. Is there anything wrong in the query? I have checked so many times ...... STATUS column is there.

Actually I am calling that function different times for different values, Every time it is giving the same exception...

thanks and regards,
madhoriya.
Aug 22 '07 #3
r035198x
13,262 MVP
Hi,
Thanks.


STATUS column is there in the table. Is there anything wrong in the query? I have checked so many times ...... STATUS column is there.

thanks and regards,
madhoriya.
I don't see anything wrong then. Try changing that count to something else too as in select .... count(*) as somethingElse
Aug 22 '07 #4
Nepomuk
3,112 Recognized Expert Specialist
Maybe there's a mistake in the definition of the table?
Aug 22 '07 #5
madhoriya22
252 Contributor
I don't see anything wrong then. Try changing that count to something else too as in select .... count(*) as somethingElse
Hi,
From somewhere i got that replacing ?(mark) with string variable will not substitue the value in query ...?

Is it right...? If it is.. then how i should try this....!!

In the 24 line of the method(see post #1) it is throwing the exception, It means it not finding that valued in the query.. Am I right?

thanks and regards,
madhoriya.
Aug 22 '07 #6
r035198x
13,262 MVP
Hi,
From somewhere i got that replacing ?(mark) with string variable will not substitue the value in query ...?

Is it right...? If it is.. then how i should try this....!!

...

thanks and regards,
madhoriya.
I doubt that. What happens if you use the index (1) to get the value in that column?
Aug 22 '07 #7
madhoriya22
252 Contributor
I doubt that. What happens if you use the index (1) to get the value in that column?
Hi,
tried ur way.. It is givign strange results...My query supposed give results like this:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. 'STATUS'    count
  3. ASSIGNED 5// this should be
  4. NEW          21// the Hashtable 
  5. REOPENED 1// contents
  6.  
But what through methods the content of Hashtable are:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. {STATUS=com.spi.defecttracker.vo.DefectReportVO@c1b531}
  3.  
and count it returnin is 27. which is total count for that column.

thanks and regards,
madhoriya
Aug 22 '07 #8
madhoriya22
252 Contributor
Hi,
tried ur way.. It is givign strange results...My query supposed give results like this:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. 'STATUS'    count
  3. ASSIGNED 5// this should be
  4. NEW         21// the Hashtable 
  5. REOPENED 1// contents
  6.  
But what through methods the content of Hashtable are:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. {STATUS=com.spi.defecttracker.vo.DefectReportVO@c1b531}
  3.  
and count it returnin is 27. which is total count for that column.

thanks and regards,
madhoriya
Hi,
Still I am not able to do it....... Is that right ...... that ?(marks) in query are only replaced by values supplied for column..... not by column Names.
Aug 23 '07 #9
r035198x
13,262 MVP
Hi,
Still I am not able to do it....... Is that right ...... that ?(marks) in query are only replaced by values supplied for column..... not by column Names.
What happens if you hardcode the colum name value in the query.
Aug 23 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
12742
by: Jan Gregor | last post by:
Hello I found that jython catches exact java exceptions, not their subclasses. Is there some way to get around this limitation (or error) ? My program has class representing database source and specialed classes for particulars databases. Now there are two options - to include exception (subclasses of SQLException) for every db in except...
3
22103
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due...
6
2422
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the UnsatisfiedLinkError has something to do with a DLL that is not visible but I'm not sure why I'm having the problem given that both db2java.zip and...
2
3938
by: technocrat | last post by:
HOW CAN THIS BE DONE IN JAVA??? THIS IS POSITIONED UPDATE EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM EMPLOYEE FOR UPDATE OF JOB; EXEC SQL OPEN C1;
4
3009
by: eviewcs | last post by:
Hello I am a newbie in DB2. I am trying out the Mapping Java definitions to SQL on UDT from the article "DB2's object-relational highlights: Store and invoke structured type objects" by Kathryn Zeidenstein. The url is : http://www-128.ibm.com/developerworks/db2/library/techarticle/ zeidenstein/0109zeidenstein.html#xforms In the article...
2
3963
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database Buildfile: build.xml env-user: prop-user: set-user:
8
28476
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive made a simple database in jsp(just to check if my mysql is working smoothly otherwise) which access' the username.....but in the process im getting a...
1
3748
by: banging | last post by:
Hi there, I have a question regarding locking of tables so that when two or more people try to write or update the mysql tables, it locks up. Basically I only want one person to write to the file, but many are able to read the files (or tables entities). I am not sure if I need to lock the tables in my Java code or do I lock the tables...
2
2604
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in another screen. All of this has to be done with java servlets. I think there's something I don't see and it's wrong. My problem is that anything I...
0
7432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.