Archive for October, 2006

I was configuring struts DS to connect to mysql today morning. i got failed day be4 yesterday, it ended with some classnot found exception. ooops! i noted tday, there was some error in the webpage i read. here is the details.

mydb name: shiksha
u/n: root
pwd: mysql

here is the datasource part of my struts-config.xml

<>
< type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
< property="driverClassName" value="com.mysql.jdbc.Driver">
< property="url" value="jdbc:mysql://localhost:3306/shiksha">
< property="username" value="root">
< property="password" value="mysql">
< property="maxActive" value="10">
< property="maxWait" value="5000">
< property="defaultAutoCommit" value="false">
< property="defaultReadOnly" value="false">
< property="validationQuery" value="SELECT COUNT(*) FROM test">
< /data-source>
< /data-sources>

and my action mapping goes like this

< path="/DataSource" type="org.shiksha.TestDB">
< name="success" path="/pages/Welcome.jsp">
< /action>

when i hit
http://localhost/shiksha/DataSource.do

I got the following in the trace

******************************************
********Out Put from TestDataSource ******
User Name is: rajesh
User Name is: george
User Name is: prakash
******************************************

Enjoy buddy, have a nice day.

help: http://forum.java.sun.com/thread.jspa?threadID=528490&messageID=2974589

here is a query to define the default value of a column.

create table test(
username varchar(20) not null default ”
) type=MyISAM;



—————————————————
*Free* software is a matter of liberty not price. You should think of "free" as in "free speech".

I am very bad at quering. I was playing with mysql yesterday and find it is very easy to create tables with foreign key relations. see the query :)

Table1: USER
——————————
user_id* | user_nick
——————————

create table user(
user_id int not null auto_increment,
primary key (user_id),
user_nick varchar(128) not null);

Table1: PROFILE
——————————
profile_id* | profile_nick
——————————
create table profile(
profile_id int not null auto_increment,
primary key(profile_id),
profile_nick varchar(128) not null);

Table1: USER_INFO
————————————————–
user_id*# | user_role# | user_name | user_avatar
————————————————–

create table user_info(
user_id int not null,
primary key (user_id),
index (user_id),
foreign key (user_id)
references user(user_id)
on update cascade
on delete restrict,
user_role int not null,
index (user_role),
foreign key (user_role)
references profile(profile_id)
on update CASCADE
on delete restrict,
user_name varchar(128),
user_avatar varchar(128)
);

Table1: PROFILE_INFO
——————————————————————–
profile_id*# | browse | own_entries | contributor | share | admin |
——————————————————————–
create table profile_info(
profile_id int not null,
primary key(profile_id),
index (profile_id),
foreign key(profile_id)
references profile(profile_id)
on update cascade
on delete restrict,
browse boolean,
own_entries boolean,
contributor boolean,
share boolean,
admin boolean);