• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Using datasource for login bean & login page?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I happened to see this code from one of the books "Making use of JSP", and is sort of what I need for the login bean for my java page:



One qn I'd like to ask: How to I change this to datasource? As I've been using datasource for my project, so I'd like to keep it constant.


Oh ya, and can someone interpret, what does this line means?



Thanks a million!
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The code seems to be working. Well, here are the answers to your questions.

1) How to I change this to datasource?

A) You can create a datasource by clicking on startmenu -> run -> type odbcad32.exe
If you are having an existing datasource then simply change the bolded word with the name of your datasource

connect=DriverManager.getConnection("jdbcdbc:MyDataSource","sa","");


2) Can someone interpret, what does this line means?

A) A result set contains the results of a SQL query. The results are kept in a set of rows, one of which is designated the current row. A row must be made current before data can be retrieved from it. The result set maintains a reference to the current row called the cursor.
The cursor is positioned before the first row when a result set is created. When a result set's next() method is called, the cursor moves to the first row of the result set and that row becomes the current row.


You can also specify the name of the column




"HELPING HANDS ARE BETTER THAN PRAYING LIPS........................."
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I also prefer column name instead of column number. It gives more readability to your code.
And the above line can be interpreted as, You are fetching value of first column which seems to be of String type and storing it into sPinNo(in addition to what ujjwal mentioned).
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ODBC is a bad choice. Use a real JDBC driver which should be shipped along the DB in question.
Regarding to the ResultSet API: go through a decent JDBC tutorial as well.
 
Jia Bin Tang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ujjwal soni wrote:Hi,

The code seems to be working. Well, here are the answers to your questions.

1) How to I change this to datasource?

A) You can create a datasource by clicking on startmenu -> run -> type odbcad32.exe
If you are having an existing datasource then simply change the bolded word with the name of your datasource

connect=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");




Oh sorry dude, what I meant was this: connecting using with JNDI as well. say like:




possible to use this (datasource) method? If so, how?
Anyway thanks for answering the other qn.
 
    Bookmark Topic Watch Topic
  • New Topic