Ravin Psinh

Greenhorn
+ Follow
since Feb 04, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ravin Psinh

leun, it may be possible because you are declaring ' i ' in the actionPerformed()........ i think you should declared it as static at the class level......... because each time you press button the event is generated and new ' i ' values are stored.....

yes you can perform operation that sql does....... here also.......... but with minor changes..........
here in our program accessing information from database returns the ResultSet object on executeQuery() method call on Statement object...............

for update, insert, delete,create ........ these all queries make changes to database so what we have to use is method executeUpdate() on Statement object......... it returns int......... (for example if you run update query than it returns the number of rows updated)..............

as you asked about updating balance of particular user........ yes we can....... we have to use WHERE clause in sql query.......
for example........

UPDATE loginTable SET balance=2000 WHERE user='ravin' AND password='1234';

for learning more about sql queries you can read w3shools SQL tutorial...... it will help faster learning.......

thanks.........
15 years ago
ok leun........ now it 100%sure the code is working........only one thing we have to make...... its not in the code........its on the
system...........

what you have to do is.....

1>open "Conrol Panel"........
2>open "Administrative Tools"
3>open "Data Sources (ODBC)"
4>click on "Add..." button
5>select a driver......"Microsoft Access Driver(*.mdb)"......from the list of driver.......
6>here in the first input box enter the ........"Data Source Name"....as "login"..... this is what program was unable to find....
7>here on the same dialog box....... you have to Select DataBase............ just locate the your database file..... in which you created the table..........
8>press OK button....................

thats all......about the creating dsn........ its helps the program to find the actual database........ its a bridge between Database and the Java Program........ via which our data will travel......... so the user and password strings...... in order to complete the journey one must specify connect the bridge properly...... that is what we have done here.........

now run the program........ if you still find problem then please post here........... we have to solve it today....

15 years ago
sorry luen i made some mistake in code..........
please correct it as follows......

replace the code which resembles like this.....


just change these two line in your code........
and one thing more..........

name of your ms-access table must be logTable as we mentioned in sql_query string............
name of data source name .......not the database name(ms-access file).......... should be login.......
and its just a entry ....... you can store or save your database anywhere in your system.........
the data source name will help the program to find it....................... because using this we are locating the database file.........
15 years ago
its working correctly
here is code for database usage .......
i am writing for simply MS-ACCESS.......




i hope this will be helpfull
15 years ago
in reading loop what you were doing is reading the file until the buffereReader.nextLine() exists rather than doing this you should just loop for about 8 iteration and then in these loop read from bufferedReader.

by this you will be able to read 8 lines.
15 years ago
if you wish to do login check with database entry than its easier . in database reading each row will be checked for user name and password. \

you can also do it with notepad where you will have to read the file and make some distinction among different users.
for this you can put a different string between the username and password and each user record starts with new line.

so your entry in notpad will be like

user1$_$_$password1
user2$_$_$password2
.
.
.
.
usern$_$_$passwordn

for checking login name and password what you have to do is to open a file reader and read line by line record and deleminate the user name and password with StringTokenizer till the match is found or the file end.
15 years ago

what is your entries in web.xml for that tag.....
as i am trying here its working fine. my entries in web.xml having many servlets for different application but its working fine....



<web-app>
<servlet>
<servlet-name>/hs</servlet-name>
<servlet-class>HelloServlet</servlet-class>
<load-on-startup>20</load-on-startup>
</servlet>
<servlet>
<servlet-name>/ls</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>





<servlet-mapping>
<servlet-name>/hs</servlet-name>
<url-pattern>/jsp123/Hello</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>/ls</servlet-name>
<url-pattern>/jsp123/login</url-pattern>
</servlet-mapping>



</web-app>
15 years ago