• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to connect to database in java class and fetch the database table

 
aish sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

NOTE:Please read the below data carefully.

I am having littlebit idea about java, not in detail. I am having an problm with database connectivity from java class and fetch the table of database.

Please see the below code, i can run the static data but i want convert it in to dynamic so please help me.i am getting an error.I amtrying to implement the below code in ZK framework. And mainPage.zul contains the code. for more clarification you can see the link "http://www.zkoss.org/zkdemo/grid/hierarchy" but here iwant to connect it to the database.








for database connectivity changes, i have tried to modify the above code but i am getting null pointer exception,





please help me to solve the above problm
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the full error message you are getting?
 
aish sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please see the below error.


 
aish sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumit Patil wrote:Can you post the full error message you are getting?


Hi Sumit , thanks for trying to help me .please see the above error
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aish,

I tried to analyze your code, but it seems, its out of my scope.

The error message states

" SEVERE: >>org.zkoss.zel.PropertyNotFoundException: Property '0' not found on type demo.grid.hierarchy.Customer "

I guess, the property '0' is not set in customer class in your code, since you are using it in your mainPage, try replacing this 0 with some property in the Customer class.

Not sure this will helps or not.
 
aish sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumit Patil wrote:Hi Aish,

I tried to analyze your code, but it seems, its out of my scope.

The error message states

" SEVERE: >>org.zkoss.zel.PropertyNotFoundException: Property '0' not found on type demo.grid.hierarchy.Customer "

I guess, the property '0' is not set in customer class in your code, since you are using it in your mainPage, try replacing this 0 with some property in the Customer class.

Not sure this will helps or not.




ok np...

i hv just debug the code and got to know my problm but not getting the solution.


please look the below two codes one is from static data which is executing correctly and one is dynamic(i.e from database) having the problm at the last line. if you can try again that will very helpful to me.

see the two code difference i am trying to make it dynamic


static code-





dynamic data(i.e from database)




i above my code is executing fine up to while staement . only there is an problm with

if you can correct this line that will solve my problm.
 
aish sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


its not executing the above line it directly goes to the
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving this to the JDBC forum, where all those chaps live/.
But my first thoughts.
you are not handling any exceptions and the close statements should be in a finally block.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aish sharma wrote:

its not executing the above line it directly goes to the


Hi,

As Wendy suggested, put catch blocks and also put all those close statements in the finally block.
As you said, the code flow is going directly going to s.close, it means the resultset you are getting does not have any results from the sql you have fired. Please do check the table in the database. Also try putting SOP in the code to see where exactly it goes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic