File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Using datasource for login bean & login page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Using datasource for login bean & login page?" Watch "Using datasource for login bean & login page?" New topic
Author

Using datasource for login bean & login page?

Jia Bin Tang
Greenhorn

Joined: Mar 06, 2008
Posts: 16
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!
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
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........................."


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374

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).
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Mar 06, 2008
Posts: 16
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("jdbcdbc: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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using datasource for login bean & login page?
 
Similar Threads
connecting and copying files in tomcat
Another DefaultTableModel post
JasperException - I got this error
NPE
struts 2: Stuck up with simple issue