星期三 2006年08月02日
CSS单元的位置和层次-div标签
CSS单元的位置和层次-div标签
我们都知道,在网页上利用HTML定位文字和图象是一件“令人心痛”的事情。我们必须使用表格标签和隐式GIF图象,即使这样也不能保证定位的精确,因为浏览器和操作平台的不同会使显示的结果发生变化。
而CSS能使你看到希望的曙光。利用今天我们即将学到的CSS属性,你可以精确地设定要素的位置,还能将定位的要素叠放在彼此之上,还有...还有......你自己慢慢看吧!
Cascading Style Sheets(CSS)是 DHTML 的基础。CSS 用来设定你网页上的元素是如何展示的。Cascading Style Sheets Positioning(CSS-P)是 CSS 的一个扩展,它可用来控制任何东西在网页上或是说在窗口中的位置。请你记住这两个名词:CSS 和 CSS-P。下面四个英文网址提供了详细的关于 CSS 和 CSS-P 的文件和解释。
● 1.使用 DIV 标签 (div)
当我们使用 CSS-P 的时候, 我们主要把它用在 DIV(division)tag 上。当你把文字,图象,或其他的放在 DIV 中,它可称作为“DIV block”,或“DIV element”或“CSS-layer”,或干脆叫“layer”。而中文我们把它称作“层次”。所以当你以后看到这些名词的时候,你就知道它们是指一段在 DIV 中的 HTML。
使用 DIV 的方法跟使用其他 tag 的方法一样:
<DIV>This is a DIV tag .</DIV>
如果单独使用 DIV 而不加任何 CSS-P, 那么它在网页中的效果和使用 <P></P> 是一样的。
但当我们把 CSS-P 用到 DIV 中去以后,我么就可以严格设定它的位置。首先我们需要给这个可以被 CSS-P 控制的 DIV 一个 ID 或说是它的名字。比如说我们给下面这个 DIV 的名字是 truck。给名字的目的是我们以后可用 JavaScript 来控制它, 比如说移动它或改变它的一些性质等等。
<DIV ID="truck">
This is a truck
</DIV>
给层次取什么名字是随意的,名字可以是任何英文字母和数字,但第一个必须是字母。有两种把 CSS-P 应用到 DIV 的方法。
Inline CSS:Inline 是最常用的方法。
<DIV ID="truck" STYLE="styles go here">
This is a truck .
</DIV>
External STYLE tag:使用 External 方法的结果是一样的。我们会在以后的课程里再详细解释这种方法。现在我们主要讨论Inline 方法。请注意在 External 方法里,在 STYLE 里的 ID 和 DIV 里的关系。
<STYLE TYPE="text/css">
<!-- #truck {styles go here} -->
</STYLE>
<DIV ID="truck">This is a truck .</DIV>
Cross-Browser CSS 性质:
我们这个课程的主要目的是让你写出的网页在 NS4 和 IE4 上都能工作, 所以我们主要讨论那些对俩者都通用的性质。下面这些性质符合由 W3C 给出的标准。
position 决定 DIV tag 是如何放置的。“relative”意思是DIV的位置是相对于其他 tag 的,而“absolute”是说 DIV tag 的位置是相对于它所在的窗口。
left 相对于窗口左边的位置
top 相对于窗口上边的位置
width DIV tag 的宽度。所有在 DIV 里的文字或html都在里面。
height DIV tag 的高度。这个性质很少用除非你想 Clip 层次。
clip 给出 layer 的 clipping(可看的见的)部分。Clip 可使得 DIV 显示为一个可以定义的很准确的方块。你可以用以下的四个值来给出这个方块的在 DIV 位置和大小。
clip:rect(top,right,bottom,left);
visibility 隐蔽或展现DIV 根据它的值“visible”,“hidden”,“inherit”。
z-index DIV tag 的立体位置。值越大 DIV 的位置越高。
background-color DIV 背景的颜色。
layer-background-color Netscape 的 DIV 背景颜色。
background-image DIV 的背景图象。
layer-background-image Netscape 的 DIV 的背景图象。
● 2.绝对定位和相对定位 (position)
绝对定位:
定位属性将是网虫们打开幸福之门的钥匙:
H4 { position: absolute; left: 100px; top: 43px }
这项CSS规则让浏览器将<H4>的起始位置精确地定在距离浏览器左边100象素,距离其顶部43象素的位置。注意这里唯一设置了的是左边和顶部,也就说,文字将从左到右,从上到下载入浏览窗口。
左边和顶部属性很直观,左边(left)设定要素距浏览器窗口左边的距离,顶部(top)设定距离浏览器窗口顶部的距离。设定这些距离时,你可以使用所学过的各种度单位或比例值。使用比例值时,比例值的是相对于母体要素的尺寸。
你可以定位什么呢?任何东西!段落、单词、GIF和JPEG图象、QUICKTIME电影等等。
相对定位:
绝对定位使你能精确地定位要素在页面的独立位置,而不考虑页面其它要素的定位设置。相对定位指你所定位的要素的位置相对于在文件中所分配的位置。例:
I { position: relative; left: 40px; top: 10px }
相对定位的关键在于定位了的要素的位置是相对于它通常应在的位置进行定位。相对定位单元出现在普通的静态定位单元的行间,定位时没有把自己和静态定位单元完全分开。如果你停止使用相对定位,则文字的显示位置将恢复正常。使用相对定位时要小心,否则容易将页面弄得非常乱。
除了相对定位和绝对定位,你还可以使用static(静止)参数值。Static 是 position 特性的缺省值。它的使用方法同普通HTML中的定位方法,不能附加特殊的定位设置。也就是说,除了边距特性,或通过使用 float 特性来浮动单元可影响单元的定位外,其它均不可以。
● 3.定位单元的控制 (width、height、visiblility)
除了控制定位单元的左上角位置,你还可以控制单元的宽度和高度,及单元在页面的可视性。
宽度:定位了的要素在页面上显示时仍然会从左到右一直显示。利用宽度属性就可以设定字符向右流动的限制,即设定要素的宽度。
DIV { position: absolute; left: 200px; top: 40px; width: 150px }
浏览器接到这项规则时,它将文字按照规则规定的效果显示,还将段落的最大水平尺寸限制在150象素。
宽度属性只适用于绝对定位的要素。你可以使用我们学过的任何一种长度单位,或使用比例值设定宽度,比例值指相对于母体要素的比例。IE 4中,这项属性还可用于图象。你可以通过宽度设置人为地拉宽或压缩图象。
高度:理论上讲,高度应该和宽度的设置类似,只不过是在垂直方向上:
DIV { position: absolute; left: 200px; top: 40px; height: 150px }
这里我用了“理论上讲”,因为有些浏览器不支持高度属性。
可视性:利用CSS,你可以隐藏要素,使其在页面上看不见。这条属性对于定位了的和未定位的要素都适用。
H4 { visibility: hidden }
选项:
visible 使要素可以被看见
hidden 使要素被隐藏
inherit 指它将继承母体要素的可视性设置。
值 inherit 为缺省值。这使单元继承父单元的可见性。所以,如果某一段是隐藏的,则它包含的任何行间单元也都被隐藏。这一继承性可被明确指定的可见性取代。例如,段内的 EM 单元被指定为可见,这时如果该段被隐藏,则段内的所有其它内容都将消失,而唯有 EM 单元中的文本是可见的。
当一个要素被隐藏后,它仍然要占据浏览器窗口中的原有空间。所以,如果你将文字包围在一幅被隐藏的图象周围,那么,其显示效果将是文字包围着一块空白区域。
此新闻这条属性在编写语言和使用动态HTML时很有用,比如你可以使某段落或图象只在鼠标滑过时才显示。
● 4.单元层次 (z-index)
特性 z-index 用于堆叠屏幕上的单元。缺省情况下,单元堆叠的顺序为它们出现在HTML标记的顺序——也就是说,后出现单元堆叠在早出现单元的上面。Z-index 特性实际上定义同属(sibling)单元的堆叠顺序以及单元相对父单元的堆叠。按照规范草案,具有正 z-index 值的单元群都堆叠在父单元之上,它们自己的堆叠顺序则按其取值的大小来决定(值大的单元在上层)。同样,具有负 z-index 值的单元群都堆叠在父单元之下,它们自己的堆叠顺序也按取值的大小来定(值大的单元在上层,例如值为 -1 的单元在值为 -2 的单元的上面)。
该参数值使用纯整数。z-index用于绝对定位或相对定位了的要素。你也可以给图象设定z-index。(对于Communicator,最好将 <IMG>标签包在<SPAN>或 <DIV>标签内,然后将z-index应用到<SPAN>或 <DIV>。)
● 5.剪辑绝对定位单元 (clip)
绝对定位单元可以被剪辑——也即剪辑显示给用户的区域,只显示单元的一部分而把其余部分作透明处理。对于传统的基于文本和图像的网络页面,这并不是一个很有用的特征。但若要求多媒体页面,这是很有用的。如 Netscape Communivator 4 和 Internet Explorer 4 都支持多媒体页面,它们通过文档的脚本接口动态地调整单元周围的剪辑区,从而实线文本“划入”和图像渐显等显示特征。
在CSS中,剪辑通过 clip 特性来控制,这一特性只能用于绝对定位单元,其缺省值为 auto,按单元的外边缘来剪辑单元(实际上等于没有剪辑)。另外,可通过如下表达式设置剪辑框:
clip : rect(top,right.bottom,left) ;
其中 top、right、bottom 和 left 分别是矩形剪辑框的上边、右边、下边和左边相对于被剪辑单元左上角的位置。Top、right、bottom 和 left 的值可以为任意绝对或相对长度值(但不能为百分比值),或者是关键字 auto。取值为 auto 意味着剪辑区域的各边放好以后,被剪辑单元中的任何内容都不会超出这个区域。
● 6.控制单元溢出 (overflow)
固定绝对或相对定位单元的 width 和 height,很可能会因为指定的区域不能满足单元实际内容的需要,而造成单元内容溢出。这时可使用 overflow 来指定浏览器如何处理溢出:值 none(缺省值)允许浏览器显示溢出的内容,因此单元可溢出指定的区域。而值 clip 要求浏览器在单元底部和右边剪辑单元内容,这样,超出指定区域的单元内容将不显示。值 scroll 也同样要求浏览器在单元底部和右边剪辑单元内容(同 clip),不过,浏览器应该(如果可能的话)为单元提供滚动条以使用户能通过滚动来浏览被剪辑的内容。
Posted at 10:51下午 八月 02, 2006 by chinafeng in General | 评论[0]
DIV+CSS布局详解
DIV+CSS布局详解
1.CSS布局常用的方法:
float : none | left | right
取值:
none : 默认值。对象不飘浮
left : 文本流向对象的右边
right : 文本流向对象的左边
它是怎样工作的,看个一行两列的例子
xhtml:
<div id="warp">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div class="clear"></div>
</div>
CSS:
#wrap{ width:100%; height:auto;}
#column1{ float:left; width:40%;}
#column2{ float:right; width:60%;}
.clear{ clear:both;}
position : static | absolute | fixed | relative
取值:
static : 默认值。无特殊定位,对象遵循HTML定位规则
absolute : 将对象从文档流中拖出,使用 left , right , top , bottom 等属性相对于其最接近的一个最有定位设置的父对象进行绝对定位。如果不存在这样的父对象,则依据 body 对象。而其层叠通过 z-index 属性定义
fixed : 未支持。对象定位遵从绝对(absolute)方式。但是要遵守一些规范
relative : 对象不可层叠,但将依据 left , right , top , bottom 等属性在正常文档流中偏移位置
它来实现一行两列的例子
xhtml:
<div id="warp">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
</div>
CSS:
#wrap{ position:relative;/*相对定位*/width:770px;}
#column1{ position:absolute; top:0; left:0; width:300px;}
#column2{position:absolute; top:0; right:0; width:470px;}
他们的区别在哪?
显然,float是相对定位的,会随着浏览器的大小和分辨率的变化而改变,而position就不行了,所以一般情况下还是float布局!
2.CSS常用布局实例
一列
单行一列
body { margin: 0px; padding: 0px; text-align: center; }
#content { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
两行一列
body { margin: 0px; padding: 0px; text-align: center;}
#content-top { margin-left:auto; margin-right:auto; width: 400px; width: 370px;}
#content-end {margin-left:auto; margin-right:auto; width: 400px; width: 370px;}
三行一列
body { margin: 0px; padding: 0px; text-align: center; }
#content-top { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
#content-mid { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
#content-end { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
两列
单行两列
#bodycenter { width: 700px;margin-right: auto; margin-left: auto;overflow: auto; }
#bodycenter #dv1 {float: left;width: 280px;}
#bodycenter #dv2 {float: right;width: 410px;}
两行两列
#header{ width: 700px; margin-right: auto;margin-left: auto; overflow: auto;}
#bodycenter { width: 700px; margin-right: auto; margin-left: auto; overflow: auto; }
#bodycenter #dv1 { float: left; width: 280px;}
#bodycenter #dv2 { float: right;width: 410px;}
三行两列
#header{ width: 700px;margin-right: auto; margin-left: auto; }
#bodycenter {width: 700px; margin-right: auto; margin-left: auto; }
#bodycenter #dv1 { float: left;width: 280px;}
#bodycenter #dv2 { float: right; width: 410px;}
#footer{ width: 700px; margin-right: auto; margin-left: auto; overflow: auto; }
三列
单行三列
绝对定位
#left { position: absolute; top: 0px; left: 0px; width: 120px; }
#middle {margin: 20px 190px 20px 190px; }
#right {position: absolute;top: 0px; right: 0px; width: 120px;}
float定位
xhtml:
<div id="warp">
<div id="column">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div class="clear"></div>
</div>
<div id="column3">这里是第三列</div>
<div class="clear"></div>
</div>
CSS:
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
float定位二
xhtml:
<div id="center" class="column">
<h1>This is the main content.</h1>
</div>
<div id="left" class="column">
<h2>This is the left sidebar.</h2>
</div>
<div id="right" class="column">
<h2>This is the right sidebar.</h2>
</div>
CSS:
body {margin: 0;padding-left: 200px;padding-right: 190px;min-width: 240px;}
.column {position: relative;float: left;}
#center {width: 100%;}
#left {width: 180px; right: 240px;margin-left: -100%;}
#right {width: 130px;margin-right: -100%;}
两行三列
xhtml:
<div id="header">这里是顶行</div>
<div id="warp">
<div id="column">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div class="clear"></div>
</div>
<div id="column3">这里是第三列</div>
<div class="clear"></div>
</div>
CSS:
#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
三行三列
xhtml:
<div id="header">这里是顶行</div>
<div id="warp">
<div id="column">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div class="clear"></div>
</div>
<div id="column3">这里是第三列</div>
<div class="clear"></div>
</div>
<div id="footer">这里是底部一行</div>
CSS:
#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
#footer{width:100%; height:auto;}
PS:这里列出的是常用的例子,而非研究之用,对一每个盒子,我都没有设置margin,padding,boeder等属性,是因为我个人觉得,含有宽度定位的时候,最好不好用到他们,除非必不得已,因为如果不是这样的话,解决浏览器兼容问题,会让你头疼,而且产生一系列CSS代码,我觉得这样的效率和效果都不好!
3.CSS布局高级技巧
margin和padding总是有可能要用到,而产生的问题如何解决呢?由于浏览器解释容器宽度的方法不同:
IE 6.0 Firefox Opera等是
真实宽度=width+padding+border+margin
IE5.X
真实宽度=width-padding-border-margin
很明显,第一种下很完美的布局在第二种情况下后果是很凄惨的!
解决的方法是 hack
div.content {
width:400px; //这个是错误的width,所有浏览器都读到了
voice-family: "\"}\""; //IE5.X/win忽略了"\"}\""后的内容
voice-family:inherit;
width:300px; //包括IE6/win在内的部分浏览器读到这句,新的数值(300px)覆盖掉了旧的
}
html>body .content { //html>body是CSS2的写法
width:300px; //支持CSS2该写法的浏览器(非IE5)有幸读到了这一句
}
div.content {
width:300px !important; //这个是正确的width,大部分支持!important标记的浏览器使用这里的数值
width(空格)/**/:400px; //IE6/win不解析这句,所以IE6/win仍然认为width的值是300px;而IE5.X/win读到这句,新的数值(400px)覆盖掉了旧的,因为!important标记对他们不起作用
}
html>body .content { //html>body是CSS2的写法
width:300px; //支持CSS2该写法的浏览器有幸读到了这一句
}
具体解释点击下面链接查看
www.blueidea.com/tech/site/2006/3170.asp
www.jluvip.com/blog/article.asp?id=114
列等高技巧
n行n列布局,每列高度(事先并不能确定哪列的高度)的相同,是每个设计师追求的目标,做法有:背景图填充、加JS脚本的
方法和容器溢出部分隐藏和列的负底边界和正的内补丁相结合的方法。
背景图填充法:
xhtml:
<div id="wrap">
<div id="column1">这是第一列</div>
<div id="column1">这是第二列</div>
<div class="clear"></div>
</div>
css:
#wrap{ width:776px; background:url(bg.gif) repeat-y 300px;}
#column1{ float:left; width:300px;}
#column2{ float:right; width:476px;}
.clear{ clear:both;}
就是将一个npx宽的一张图片在外部容器纵向重复,定位到两列交错的位置纵向重复,在视觉上产生了两列高度一样的错觉
JS脚本法:
www.blueidea.com/bbs/NewsDetail.asp?id=2453983
代码的原理基本就是这样,读取高度,判断高度,高度相等。
容器溢出部分隐藏和列的负底边界和正的内补丁相结合的方法
这篇文章说的很详细了:
www.blueidea.com/tech/web/2006/3210.asp
还有:
www.jluvip.com/blog/article.asp?id=151
满屏高度布局(最窄770px最宽1024px经典布局)
www.blueidea.com/tech/web/2005/3124.asp
今天和一个网友两天,他提到:给一个外国公司做网站,要求1.800x600满屏。2.1024x767满屏。3.1280下居中。4.不许用JS。
我突然想起了这篇文章,哈哈!把它感觉不可思议的事情解决了!但是好像对于IE5有点问题啊!
经典论坛讨论帖:
http://www.blueidea.com/bbs/NewsDetail.asp?id=2506047
--------------------------------------------------------------------------------
发贴人: 松风丁丁 时间: 2006-05-25 06:52 上午
原作者:Alex Robinson
原文标题:Equal Height Columns
这是一个比较典型的三行二列布局,每列高度(事先并不能确定哪列的高度)的相同,是每个设计师追求的目标,按一般的做法,大多采用背景图填充、加JS脚本的方法使列的高度相同,本文要介绍的是采用容器溢出部分隐藏和列的负底边界和正的内补丁相结合的方法来解决列高度相同的问题。
先看代码:
#wrap{
overflow: hidden;
}
#sideleft, #sideright{
padding-bottom: 32767px;
margin-bottom: -32767px;
}
实现原理:
块元素必须包含在一个容器里。
应用overflow: hidden 到容器里的元素。
应用 padding-bottom(足够大的值)到列的块元素 。
应用margin-bottom(足够大的值)到列的块元素。
padding-bottom将列拉长变的一样高,而负的margin-bottom又使其回到底部开始的位置,同时,溢出部分隐藏掉了。
兼容各浏览器
IE Mac 5
得到高度正确,所以要过滤掉上面的代码。
/*\*/
#sideleft, #sideright{
padding-bottom: 32767px;
margin-bottom: -32767px;
}
/**/
Opera
1. Opera7.0-7.2不能正确清除溢出部分,所以要加:
/* easy clearing */
#wrap:after
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#wrap
{
display: inline-block;
}
/*\*/
#wrap
{
display: block;
}
/* end easy clearing */
/*\*/
2. Opera8处理overflow: hidden有个BUG,还得加上以下代码:
/*\*/
#sideleft, #sideright
{
padding-bottom: 32767px !important;
margin-bottom: -32767px !important;
}
@media all and (min-width: 0px) {
#sideleft, #sideright
{
padding-bottom: 0 !important;
margin-bottom: 0 !important;
}
#sideleft:before, #sideright:before
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
background: inherit;
padding-top: 32767px !important;
margin-bottom: -32767px !important;
height: 0;
}
}
/**/
3.Opera9的B2在修正8的bug.
测试环境:IE5.01、IE5.5、IE6.0、Firefox1.5、Opera8.5、Netscape 7.2通过。
Posted at 10:32下午 八月 02, 2006 by chinafeng in General | 评论[0]
CVS资源
http://www.xfocus.net/articles/200112/314.html
http://www.xfocus.net/articles/200112/314.html
Posted at 02:46下午 八月 02, 2006 by chinafeng in General | 评论[0]
星期四 2006年06月29日
要离开学校了
大学终于结束了,同学都走了,宿舍楼只有几个人还在学校,这几天也都要走了,走下楼梯的感觉真的很伤感,很失落,曾经热热闹闹的宿舍楼一下子变成这样,很想哭.
Posted at 08:38下午 六月 29, 2006 by chinafeng in General | 评论[0]
星期六 2006年05月06日
终于搞定Proxoll和Spring了
搞了几天终于搞定,就是不知道是不是会稳定,还得过段时间再看。
把代码帖出来:
<!-- c3p0 0.9.0.4 DateSource -->
<bean id="c3P0DataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.user}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize"
value="${c3p0.initialPoolSize}" />
<property name="minPoolSize" value="${c3p0.minPoolSize}" />
<property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
<property name="acquireIncrement"
value="${c3p0.acquireIncrement}" />
<property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
<property name="maxStatements" value="${c3p0.maxStatements}" />
</bean>
<!-- Proxool 0.9.0rc2 DataSource -->
<!-- may have some unknow exception -->
<bean class="org.logicalcobwebs.proxool.ProxoolDataSource"
destroy-method="close" id="proxoolDataSource">
<property name="alias" value="${proxool.alias}" />
<property name="driver" value="${jdbc.driver}" />
<property name="driverUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.user}" />
<property name="password" value="${jdbc.password}" />
<property name="maximumConnectionCount" value="${proxool.max}" />
<property name="minimumConnectionCount" value="${proxool.min}" />
<property name="houseKeepingSleepTime" value="${proxool.keep}" />
<property name="prototypeCount" value="${proxool.proto}" />
<property name="trace" value="${proxool.trace}" />
</bean>
<!-- jdbcTemplate -->
<bean class="org.springframework.jdbc.core.JdbcTemplate"
id="jdbcTemplate">
<property name="dataSource" ref="proxoolDataSource" />
</bean>
# DateSource Pool
# Oracle
# jdbc.driver=oracle.jdbc.driver.OracleDriver
# jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:Violet
# this is only for the proxool pool
# jdbc.url=jdbc:oracle:thin:Violet/Violet@127.0.0.1:1521:Violet
# MySQL
jdbc.driver=com.mysql.jdbc.Driver
# this only for the prxool pool
jdbc.url=jdbc:mysql://localhost:3306/Violet?useUnicode=true&characterEncoding=GB2312&user=Violet&password=Violet
# jdbc.url=jdbc:mysql://localhost:3306/Violet
jdbc.user=Violet
jdbc.password=Violet
# C3P0
c3p0.initialPoolSize=10
c3p0.minPoolSize=10
c3p0.maxPoolSize=20
c3p0.acquireIncrement=5
c3p0.maxIdleTime=20
c3p0.maxStatements=50
# Porxool
proxool.alias=Violet
proxool.max=20
proxool.min=10
proxool.keep=100000
proxool.proto=5
proxool.trace=true
# Dialect
# Oracle
# hibernate.dialect=org.hibernate.dialect.OracleDialect
# MySQL
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.default_batch_fetch_size=8
hibernate.max_fetch_depth=2
hibernate.jdbc.batch_size=20
hibernate.show_sql=true
hibernate.cache.use_query_cache=true
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
# Hibernate Proxool DbPool
hibernate.proxool.xml=com/violet/db/ProxoolConf.xml
hibernate.proxool.pool_alias=Violet
<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>Violet</alias>
<!--
<driver-url>
jdbc:mysql://localhost:3306/Violet?useUnicode=true&characterEncoding=GB2312
</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
-->
<driver-url>
jdbc:oracle:thin:@127.0.0.1:1521:Violet
</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="Violet" />
<property name="password" value="Violet" />
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<maximum-new-connections>20</maximum-new-connections>
<prototype-count>5</prototype-count>
<maximum-connection-count>20</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>
<!-- Hibernate SessionFatory-->
<bean
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
id="hibernateSessionFactory">
<!-- -->
<property name="dataSource" ref="proxoolDataSource" />
<!---->
<property name="mappingResources">
<list>
<value>com/violet/bean/hbm/Users.hbm.xml</value>
<value>com/violet/bean/hbm/Groups.hbm.xml</value>
<value>com/violet/bean/hbm/UsersGroups.hbm.xml</value>
<value>
com/violet/bean/hbm/GroupsReources.hbm.xml
</value>
<value>com/violet/bean/hbm/Reources.hbm.xml</value>
<value>com/violet/bean/hbm/Permissions.hbm.xml</value>
<value>com/violet/bean/hbm/Messages.hbm.xml</value>
<value>com/violet/bean/hbm/Parts.hbm.xml</value>
<value>com/violet/bean/hbm/Boards.hbm.xml</value>
<value>com/violet/bean/hbm/Topics.hbm.xml</value>
<value>com/violet/bean/hbm/Replies.hbm.xml</value>
<value>com/violet/bean/hbm/BlogReplies.hbm.xml</value>
<value>com/violet/bean/hbm/BlogTopics.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<!-- User the proxoolConfig file -->
<!--
<prop key="hibernate.proxool.xml">
${hibernate.proxool.xml}
</prop>
<prop key="hibernate.proxool.pool_alias">
${hibernate.proxool.pool_alias}
</prop>
-->
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.cache.use_query_cache">
${hibernate.cache.use_query_cache}
</prop>
<prop key="hibernate.default_batch_fetch_size">
${hibernate.default_batch_fetch_size}
</prop>
<prop key="hibernate.max_fetch_depth">
${hibernate.max_fetch_depth}
</prop>
<prop key="hibernate.jdbc.batch_size">
${hibernate.jdbc.batch_size}
</prop>
<prop key="hibernate.cache.provider_class">
${hibernate.cache.provider_class}
</prop>
</props>
</property>
</bean>
Posted at 12:30上午 五月 06, 2006 by chinafeng in General | 评论[204]
星期日 2006年04月23日
Spring
http://www.jroller.com/page/raible?anchor=using_commons_validator_with_spring
http://jroller.com/page/habuma?entry=spring_form_tags
http://opensource.atlassian.com/confluence/spring/display/DISC/Multiple+Validators+per+Controller
http://www.jroller.com/page/habuma?entry=spring_form_tags
http://javaguru.fi/2006/03/22/spring-form-tags/
Posted at 10:54上午 四月 23, 2006 by chinafeng in General | 评论[0]
星期六 2006年04月15日
Web Tier to Go With Java EE 5系列
Web Tier to Go With Java EE 5:
http://java.sun.com/developer/technicalArticles/J2EE/jsp_21/
http://java.sun.com/developer/technicalArticles/J2EE/jsf_12/
http://java.sun.com/developer/technicalArticles/J2EE/jstl/
Posted at 10:21下午 四月 15, 2006 by chinafeng in General | 评论[0]
星期日 2006年04月09日
Getting Started with DWR
Getting Started with DWR
There are 2 ways to get started with DWR, the easy way is to download the WAR file and have a look around, however this does not help you see how easily DWR integrates with your current web application, so the following 3 simple steps are recommended:
1. Install the DWR JAR file
Download the dwr.jar file. Place it in the WEB-INF/lib directory of your webapp. You'll probably have a set of jar files in there already.
2. Edit the config files
The following lines need to be added to WEB-INF/web.xml. The
Then create a dwr.xml file that lives in WEB-INF alongside web.xml. A simple way to start is with something like this:
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
The DWR config file defines what classes DWR can create and remote for use by Javascript. In the example above we are defining 2 classes that are remoted and giving the classes names in Javascript.
The new creator that we used above uses the public no-args constructor that all JavaBeans must have. It is also worth remembering that DWR has a few restrictions:
Avoid reserved JavaScript words; Methods named after reserved words are automatically excluded. Most JavaScript reserved words are also Java reserved words, so you won't be having a method called "try()" anyway. However the most common gotcha is "delete()", which has special meaning from JavaScript but not Java.
Overloaded methods can be involved in a bit of a lottery as to which gets called, so avoid overloaded methods.
3. Go to the following URL
http://localhost:8080/[YOUR-WEBAPP]/dwr/
You should see a page showing you the classes that you've selected in step 2. Having followed a link you should see an index of all the methods all ready for calling. These pages are dynamically generated examples of what you can do using DWR.
Kick the tyres and have a look around.
How to make use of this from your web application
There are a number of examples in the sidebar that demonstrate how to dynamically alter the text in web pages, update lists, manipulate forms and do live table editing. Each has a description of how it works.
Another way to get started is to look at the source from the pages that you just viewed:
Go to http://localhost:8080/[YOUR-WEBAPP]/dwr/ and click on you class
View source and find the line that executes the method that you are interested in.
Paste the text into an HTML or JSP page in your web-app.
Include links to the javascript files that make the magic happen:
You can omit the /[YOUR-WEBAPP]/ section and use relative paths in your web pages if you wish.
For more information about how to write Javascript that interacts with DWR see the scripting introduction.
What if it doesn't work?
We have a log of common problems and their fixes. This is the first place to look.
If you are still having problems please join the mailing list and ask there.
Posted at 01:03下午 四月 09, 2006 by chinafeng in General | 评论[0]
eclipse快捷键
Ctrl+1 快速修复(最经典的快捷键,就不用多说了)
Ctrl+D: 删除当前行
Ctrl+Alt+↓ 复制当前行到下一行(复制增加)
Ctrl+Alt+↑ 复制当前行到上一行(复制增加)
Alt+↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)
Alt+↑ 当前行和上面一行交互位置(同上)
Alt+← 前一个编辑的页面
Alt+→ 下一个编辑的页面(当然是针对上面那条来说了)
Alt+Enter 显示当前选择资源(工程,or 文件 or文件)的属性
Shift+Enter 在当前行的下一行插入空行(这时鼠标可以在当前行的任一位置,不一定是最后)
Shift+Ctrl+Enter 在当前行插入空行(原理同上条)
Ctrl+Q 定位到最后编辑的地方
Ctrl+L 定位在某行 (对于程序超过100的人就有福音了)
Ctrl+M 最大化当前的Edit或View (再按则反之)
Ctrl+/ 注释当前行,再按则取消注释
Ctrl+O 快速显示 OutLine
Ctrl+T 快速显示当前类的继承结构
Ctrl+W 关闭当前Editer
Ctrl+K 参照选中的Word快速定位到下一个
Ctrl+E 快速显示当前Editer的下拉列表(如果当前页面没有显示的用黑体表示)
Ctrl+/(小键盘) 折叠当前类中的所有代码
Ctrl+×(小键盘) 展开当前类中的所有代码
Ctrl+Space 代码助手完成一些代码的插入(但一般和输入法有冲突,可以修改输入法的热键,也可以暂用Alt+/来代替)
Ctrl+Shift+E 显示管理当前打开的所有的View的管理器(可以选择关闭,激活等操作)
Ctrl+J 正向增量查找(按下Ctrl+J后,你所输入的每个字母编辑器都提供快速匹配定位到某个单词,如果没有,则在stutes line中显示没有找到了,查一个单词时,特别实用,这个功能Idea两年前就有了)
Ctrl+Shift+J 反向增量查找(和上条相同,只不过是从后往前查)
Ctrl+Shift+F4 关闭所有打开的Editer
Ctrl+Shift+X 把当前选中的文本全部变味小写
Ctrl+Shift+Y 把当前选中的文本全部变为小写
Ctrl+Shift+F 格式化当前代码
Ctrl+Shift+P 定位到对于的匹配符(譬如{}) (从前面定位后面时,光标要在匹配符里面,后面到前面,则反之)
下面的快捷键是重构里面常用的,本人就自己喜欢且常用的整理一下(注:一般重构的快捷键都是Alt+Shift开头的了)
Alt+Shift+R 重命名 (是我自己最爱用的一个了,尤其是变量和类的Rename,比手工方法能节省很多劳动力)
Alt+Shift+M 抽取方法 (这是重构里面最常用的方法之一了,尤其是对一大堆泥团代码有用)
Alt+Shift+C 修改函数结构(比较实用,有N个函数调用了这个方法,修改一次搞定)
Alt+Shift+L 抽取本地变量( 可以直接把一些魔法数字和字符串抽取成一个变量,尤其是多处调用的时候)
Alt+Shift+F 把Class中的local变量变为field变量 (比较实用的功能)
Alt+Shift+I 合并变量(可能这样说有点不妥Inline)
Alt+Shift+V 移动函数和变量(不怎么常用)
Alt+Shift+Z 重构的后悔药(Undo)
Ctrl+Shift+U 选择选中的文字后非常类似于UE的列表查询
右键菜单
JPopupMenu
Posted at 10:43上午 四月 09, 2006 by chinafeng in General | 评论[0]
Red Hat中RPM命令的使用
Red Hat中RPM命令的使用
RPM全称是 Red Hat Package Manager(Red Hat包管理器)。几乎所有的 Linux 发行版本都使用这种形式的软件包管理安装、更新和卸载软件。下面就RPM命令的使用做简单的介绍。
一、安装
命令格式:
rpm -i ( or --install) options file1.rpm ... fileN.rpm
参数:
file1.rpm ... fileN.rpm 将要安装的RPM包的文件名
详细选项:
-h (or hash) 安装时输出hash记号 (``#)test 只对安装进行测试,并不实际安装。
percent 以百分比的形式输出安装的进度。excludedocs 不安装软件包中的文档文件
includedocs 安装文档replacepkgs 强制重新安装已经安装的软件包
replacefiles 替换属于其它软件包的文件force 忽略软件包及文件的冲突
noscripts 不运行预安装和后安装脚本prefix 将软件包安装到由 指定的路径下
ignorearch 不校验软件包的结构ignoreos 不检查软件包运行的操作系统
nodeps 不检查依赖性关系ftpproxy 用 作为 FTP代理
--ftpport 指定FTP的端口号为
通用选项
-v 显示附加信息
-vv 显示调试信息
root 让RPM将指定的路径做为"根目录",这样预安装程序和后安装程序都会安装到这个目录下rcfile 设置rpmrc文件为
--dbpath 设置RPM 资料库存所在的路径为
二、删除
命令格式:
rpm -e ( or erase) options pkg1 ... pkgN
参数
pkg1 ... pkgN :要删除的软件包
详细选项
test 只执行删除的测试
noscripts 不运行预安装和后安装脚本程序nodeps 不检查依赖性
通用选项
-vv 显示调试信息
root 让RPM将指定的路径做为"根目录",这样预安装程序和后安装程序都会安装到这个目录下rcfile 设置rpmrc文件为
--dbpath 设置RPM 资料库存所在的路径为
三、升级
命令格式
rpm -U ( or --upgrade) options file1.rpm ... fileN.rpm
参数
file1.rpm ... fileN.rpm 软件包的名字
详细选项
-h (or hash) 安装时输出hash记号 (``#)oldpackage 允许"升级"到一个老版本
test 只进行升级测试excludedocs 不安装软件包中的文档文件
includedocs 安装文档replacepkgs 强制重新安装已经安装的软件包
replacefiles 替换属于其它软件包的文件force 忽略软件包及文件的冲突
percent 以百分比的形式输出安装的进度。noscripts 不运行预安装和后安装脚本
prefix 将软件包安装到由 指定的路径下ignorearch 不校验软件包的结构
ignoreos 不检查软件包运行的操作系统nodeps 不检查依赖性关系
ftpproxy 用 作为 FTP代理ftpport 指定FTP的端口号为
通用选项
-v 显示附加信息
-vv 显示调试信息
root 让RPM将指定的路径做为"根目录",这样预安装程序和后安装程序都会安装到这个目录下rcfile 设置rpmrc文件为
--dbpath 设置RPM 资料库存所在的路径为
四、查询
命令格式:
rpm -q ( or --query) options
参数:
pkg1 ... pkgN :查询已安装的软件包
详细选项
-p (or ``-'') 查询软件包的文件
-f 查询属于哪个软件包
-a 查询所有安装的软件包
--whatprovides 查询提供了 功能的软件包
-g 查询属于 组的软件包
--whatrequires 查询所有需要 功能的软件包
信息选项
显示软件包的全部标识
-i 显示软件包的概要信息
-l 显示软件包中的文件列表
-c 显示配置文件列表
-d 显示文档文件列表
-s 显示软件包中文件列表并显示每个文件的状态
scripts 显示安装、卸载、校验脚本queryformat (or
qf) 以用户指定的方式显示查询信息dump 显示每个文件的所有已校验信息
provides 显示软件包提供的功能requires (or -R) 显示软件包所需的功能
通用选项
-v 显示附加信息
-vv 显示调试信息
root 让RPM将指定的路径做为"根目录",这样预安装程序和后安装程序都会安装到这个目录下rcfile 设置rpmrc文件为
--dbpath 设置RPM 资料库存所在的路径为
五、校验已安装的软件包
命令格式:
rpm -V ( or --verify, or -y) options
参数
pkg1 ... pkgN 将要校验的软件包名
软件包选项
-p Verify against package file
-f 校验所属的软件包
-a Verify 校验所有的软件包
-g 校验所有属于组 的软件包
详细选项
noscripts 不运行校验脚本nodeps 不校验依赖性
--nofiles 不校验文件属性
通用选项
-v 显示附加信息
-vv 显示调试信息
root 让RPM将指定的路径做为"根目录",这样预安装程序和后安装程序都会安装到这个目录下rcfile 设置rpmrc文件为
--dbpath 设置RPM 资料库存所在的路径为
六、校验软件包中的文件
语法:
rpm -K ( or checksig) options file1.rpm ... fileN.rpm
参数:
file1.rpm ... fileN.rpm 软件包的文件名
Checksig详细选项
--nopgp 不校验PGP签名
通用选项
-v 显示附加信息
-vv 显示调试信息
rcfile 设置rpmrc文件为
七、其它RPM选项
rebuilddb 重建RPM资料库
initdb 创建一个新的RPM资料库quiet 尽可能的减少输出
help 显示帮助文件version 显示RPM的当前版本
Posted at 10:41上午 四月 09, 2006 by chinafeng in General | 评论[0]
Oracle 10G 在fedora core4上的安装
Oracle 10G 在fedora core4上的安装
安装步骤:
1.当然是下载软件包:http://www.oracle.com/technology ... racle10g/index.html
选择自己需要的 .我下载的是:for linux x86.(注意,下载前需要先注册用户)
2.解压
gunzip ship.db.lix32.cpio.gz
cpio -idmv < ship.db.lix32.cpio
解压后在当前目录下形成目录 Disk1.
3.打开帮助文件.Quick Installation Guide for Linux x86
在Disk1/目录下有个DOC目录,打开里面的README文件,其中就有此帮助文件
4.安帮助一步步设至.基本没有问题.
5.很重要,因为ORACLE10g不支持FC4,所以需作必要修改.
z找到文件./Disk1/install/oraparam.ini,打开,删除如下内容(记得先备份)
[Certified Versions]
Linux=redhat-2.1,redhat-3,SuSE-9,SuSE-8,UnitedLinux-1.0
[UnitedLinux-1.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-redhat-2.1-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-redhat-3.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-SuSE-9-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-SuSE-8-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
6.设置语言支持.由于ORACLE安装界面中文支持不好,建议运行
export LC_ALL=en_us,否则容易出现乱码.
好了 ,现在运行./runInstall.安向导往下走就可以了
Posted at 10:40上午 四月 09, 2006 by chinafeng in General | 评论[0]
星期六 2006年04月08日
xmms中文列表的解决
看了网上很多文章都解决不了,自己搞了一个下午,终于搞定
首先把这个复制到字体中
-adobe-helvetica-medium-r-normal--16-*-*-*-*-*-iso8859-1,
-*-*-medium-r-normal--16-*-*-*-*-*-gb2312.1980-0,*-r-*
选中x-字体,使用字体集不要选,说白了,我不理解,以上都是在FC5下成功。
Posted at 05:35下午 四月 08, 2006 by chinafeng in General | 评论[1]
星期四 2006年04月06日
DB Link
drop database link dht2005
create database link dht2005
connect to dht identified by dht
using '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.6)(PORT=1521)))(CONNECT_DATA=(SID=dhtdba)(SERVER=DEDICATED)))';
show parameters global_name
SELECT * FROM V$DBLINK
SELECT * FROM DBA_DB_LINKS;
SELECT * FROM USER_DB_LINKS
select * from goods@dht2005 where goods_no < 10
select * from goods where goods_no < 10
select * from ck_goods where ck_goods_no < 100;
select * from ck_goods@dht2005 where ck_goods_no < 100;
select * from goods@dht2005
update goods set unit_name='s' where goods_no=1
update goods@dht2005 set unit_name='个' where goods_no=1
commit
Posted at 12:35下午 四月 06, 2006 by chinafeng in General | 评论[0]
DBA Linking to Remote Databases
Database links are an essential method of defining paths to other databases in a distributed environment, enabling seamless remote transactions.
| For in-depth information on database links, see the Oracle8i SQL Reference and Oracle8i Concepts manuals. Another excellent source of detailed information is the Oracle8i Distributed Database Systems manual. |
How do you link two databases together? You do so by using a database link. A database link is an object in one database that defines a path to another. Database links allow you to query remote tables and execute remote procedures. They are essential in any distributed environment.
The net service name is necessary for every database link. You use net service names each time you use SQL*Plus to connect to your database from a client PC. In those cases, the net service names you provide to SQL*Plus are resolved by looking them up in a tnsnames.ora file on your client. The same thing happens with the net service names used in database links, except then those names are resolved using the tnsnames.ora file that resides on the server.
The username and password that you specify when defining a database link are used to establish the connection to the remote instance. It's possible, and even desirable, to create database links without hardcoding a username and password. For now, though, let's concentrate on the most straightforward case.
The following statement creates a database link that allows access to a guest account that has previously been established on the GNIS database:
CREATE DATABASE LINK GNIS
CONNECT TO GUEST IDENTIFIED BY WELCOME
USING 'GNIS';
The link name follows the LINK keyword, and is GNIS. The CONNECT TO...IDENTIFIED BY clause specifies GUEST/WELCOME as the username and password to use when connecting to the remote instance. The USING clause specifies that the connection be established through the net service name GNIS. Using the link, you can now query data in the remote database. For example:
SQL> SELECT GFN_FEATURE_NAME
2 FROM GNIS.FEATURE_NAMES@GNIS
3 WHERE GFN_FEATURE_TYPE='falls'
4 AND GFN_STATE_ABBR='MI'
5 AND GFN_COUNTY_NAME='Alger';
GFN_FEATURE_NAME
_________________
Alger Falls
Au Train Falls
Chapel Falls
Miners Falls
Mosquito Falls
Tannery Falls
...
The @GNIS following the table name in the SELECT statement indicates that the GNIS.FEATURE_NAMES table is in a remote database and should be accessed via the GNIS link, as shown in Figure 1.
Each time you create a database link, you make these three choices, whether consciously or not.
PUBLIC keyword as shown here: CREATE PUBLIC DATABASE LINK GNIS
CONNECT TO GUEST IDENTIFIED BY WELCOME
USING 'GNIS';
Even though this is a public link, the username is still fixed. All users using this link will connect to the remote database as the user GUEST.
|
| FIGURE 1. The database link GNIS, specifies the net service name, linking the PROD instance to the FEATURE_NAMES table in the GNIS instance. |
CURRENT_USER keyword. A fixed user database link is one in which the username and password for the remote database are specified when the link is created. Whenever the link is used, no matter who uses it, that same username and password are used to log on to the remote database. The links you've seen so far in this article are fixed user links.
A potential problem with fixed user links, especially for public fixed user links, is that they give multiple local users access to the same account on a remote system. From a security standpoint, accountability may be compromised, depending on the number of users, if all local users have the same account on the remote system. If data is lost, it is nearly impossible to determine how the damage occurred. Another potential issue is that a public fixed user link gives all users of a local database access to the remote database.
If you don't want to embed a username and password within a database link, Oracle provides you with another, very useful, option. You can create a connected user link. A connected user database link is one that logs on to the remote database with the username and password of whichever local database user is using the link. You create a connected user link by simply leaving off the user name and password. Consider the following definition:
CREATE PUBLIC DATABASE LINK GNIS
USING 'GNIS';
The link name is GNIS. The net service name it uses to connect to the remote database is GNIS, but no username and password have been specified. When you use this link in a query, it will send your current username and password to the remote database. For example, if you logged on to your local database using AHMAD/SECRET, then AHMAD/SECRET is the username and password that will be used to log on to the remote database.
It's important to understand that you must have an account on the remote database in order to use a connected user link. Not only that, but your usernames and passwords on both databases must be identical. If you log on locally as AHMAD/SECRET, then you must also be able to log on to the remote database using that same username and password. If your passwords are different, you will fail to authenticate when using a connected user link.
Public connected user database links are particularly useful, because you can create one link for all users to access, and yet each user is authenticated individually using his or her own username and password. You reap the benefits of accountability, and you don't leave the remote database open to every user on your local database. The tradeoff is you must create user accounts on both databases, and you must ensure that the passwords remain synchronized.
Current user links are created by using the CURRENT_USER keyword and are similar to connected user links. You can use current user links only if you are using the Oracle Advanced Security Option, and the links are only usable by global users who authenticate using X.509 certificates.
On the surface, shared links immediately sound like a good thing, and for certain environments they are, but there are some limitations and caveats that you need to be aware of when considering the use of a shared link:
You create a shared database link using the SHARED keyword. You also need to use the AUTHENTICATED BY clause to specify a valid username and password on the remote system. The following command creates a shared, public, connected user database link:
CREATE SHARED PUBLIC DATABASE LINK GNIS
AUTHENTICATED BY DUMMY_USER IDENTIFIED BY SECRET
USING 'GNIS';
| For more information on creating links and managing distributed systems, see the Oracle Technology Network (/technology/index.html). |
AUTHENTICATED BY clause is somewhat confusing, but it's necessary for security because of the way that shared links are implemented. The user name and password, DUMMY_USER/SECRET in this example, do need to be valid on the remote system. However, the account used on the remote system is still that of the connected user. If I log on to my local database as AHMAD/SECRET and use the shared link that I have just created, the following sequence of events will occur:
DUMMY_USER/SECRET in order to open the link. AHMAD/SECRET. The main purpose of a shared link is to reduce the number of underlying network connections between two database servers. They are best suited for MTS environments where you have large numbers of users accessing remote data through the link. Ideally, you want the user count to exceed the number of shared server processes. Then you save resources by opening only one link per shared server process rather than one link per user.
DBA_DB_LINKS view returns one row for every link defined. The OWNER and DB_LINK columns show the link's owner and name respectively. The OWNER column will contain 'PUBLIC' for public database links. If you create a fixed user link, the username will be in the USERNAME column of the DBA_DB_LINKS view, but the password will be visible only from the SYS.LINK$ view. By default, only DBAs who have the SELECT ANY TABLE system privilege can access the SYS.LINK$ view and see passwords. You should protect access to that view. The ALL_DB_LINKS and USER_DB_LINKS views are similar to DBA_DB_LINKS—they respectively show all links to which you have access, and all links owned by you. Finally, the V$DBLINK dynamic performance view shows you all the database links that you, the current user, have open at any given time. Jonathan Gennick is an Oracle Certified Professional, and a writer who loves to explore Oracle technologies. Jonathan is coauthor, along with Hugo Toledo, of Oracle Net8 Configuration and Troubleshooting (O'Reilly & Associates; ISBN: 1-56592-753-2).
| Global Database Names |
In a distributed environment, Oracle recommends that your database link names match the global names of the databases to which they are connecting. Thus, if you were connecting to a database named GNIS.GENNICK.ORG, you would name your database link GNIS.GENNICK.ORG. To determine the global name for a database, log on as SYSTEM and query the GLOBAL_NAME view:
GLOBAL_NAME For historical reasons, the link between global names and database link names is not enforced by default. However, you can change that behavior by setting the GLOBAL_NAMES initialization parameter to TRUE. For example:
NAME TYPE VALUE The instance used to generate this example will require that any database link name you use must match the global database name of the target database. Note that contrary to what some of Oracle's documentation says, it is the |
Posted at 09:36上午 四月 06, 2006 by chinafeng in General | 评论[0]