una_noche
06-21-2007, 06:00 AM
Hello everyone..
i'm a new coder here and totally a beginner programmer especially in JSP.
I have a problem how to create auto-increment process in database and also in JSP.
Could any one here give me some example and step how to create it?
I really need some help here..~
Thank You...~
auto-increment is usually implemented at the database layer. For example, if we have a table in MySQL and it is define as:
table users {
id int(13) not null auto_increment,
name varchar( 45 ) not null default '',
email varchar( 55 ) not null default '',
website varchar( 100 ) not null default '',
primary key( id )
}
As you can see from the above definition, the "id" should be automatically incremented by the database. Therefore, when we want to insert data into that particular table, we could execute the following command without specifying the "id" field...as we want the database to handle it on our behalf
INSERT INTO `user` ( `name`, `email`, `website` ) VALUES ( 'John Smith', 'john@smiths.com', 'www.john-smith.com' ) ;
The above statement can be executed the same way outside, or inside a JSP page.
If you are not sure about JDBC and how it works, here is a good tutorial that demonstrates JDBC connections, data manipulations etc.
http://java.sun.com/docs/books/tutorial/jdbc/
Cheers,
Ess
una_noche
06-26-2007, 02:31 AM
how about if the table already exist?
it is necessary to create again the table?
and how about sequence and triggers? :confused:
can u explain about it?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.