??xml version="1.0" encoding="utf-8" standalone="yes"?>www.综合,99国产麻豆精品,成人免费图片免费观看http://www.aygfsteel.com/crazycy/category/8596.html记录Ҏ 鉴往事之得失 以资于发?zh-cnThu, 06 Mar 2014 16:02:08 GMTThu, 06 Mar 2014 16:02:08 GMT60Database-001 MySQL存储引擎MyISAM与InnoDB的主要区别对?(转)http://www.aygfsteel.com/crazycy/archive/2014/03/06/410673.htmlcrazycycrazycyThu, 06 Mar 2014 03:09:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/03/06/410673.htmlhttp://www.aygfsteel.com/crazycy/comments/410673.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/03/06/410673.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/410673.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/410673.html本文整理?a title="Mysql" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">Mysql 两大常用的存储引?a title="MyISAM" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">MyISAMQ?a title="InnoDB" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">InnoDB的六大常见区别,来源?a title="Mysql" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">Mysql手册以及互联|的资料?/p>
InnoDB?/strong>Myisam的六大区?/strong>
MyISAMInnoDB
?成上的区别:每个MyISAM在磁盘上存储成三个文件。第一?文g的名字以表的名字开始,扩展名指出文件类型?p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">

.frm文g存储表定义?br />数据文g的扩 展名?MYD (MYData)?/span>索引文g的扩 展名?MYI (MYIndex)?/span>

Z盘的资源是InnoDB表空间数据文件和它的日志文gQInnoDB 表的 大小只受限于操作pȝ文g的大,一般ؓ 2GB
事务处理上方?/strong>:MyISAMcd的表的是性能Q其执行?度比InnoDBcd更快Q但是不提供事务支持InnoDB提供事务支持事务(commit, rollback, crash recovery capability)Q外部键{高U?数据库功?br />
SELECTUPDATE,INSERTQ?/strong>Delete??/strong>如果执行大量的SELECTQMyISAM是更好的选择1.如果你的数据执行大量?strong style="padding: 0px; margin: 0px;">INSERT?/strong>UPDATEQ出于性能斚w的考虑Q应该用InnoDB?p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">

2.DELETE FROM tableӞInnoDB不会重新建立表,而是一行一行的 删除?/p>

3.LOAD TABLE FROM MASTER操作对InnoDB是不起作用的Q解x法是首先把InnoDB表改成MyISAM表,导入数据后再ҎInnoDB表,但是对于使用的额外的InnoDBҎ(例如外键Q的表不适用

?/strong>AUTO_INCREMENT?操作

每表一个AUTO_INCREMEN列的内部处理?p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">

MyISAM?/strong>INSERT?/strong>UPDATE?作自动更新这一?/strong>。这使得AUTO_INCREMENT列更快(臛_10%Q。在序列的D删除之后׃ 能再利用?当AUTO_INCREMENT列被定义为多列烦引的最后一列, 可以出现重用从序列剙删除的值的情况Q?/p>

AUTO_INCREMENT值可用ALTER TABLE或myisamch来重|?/p>

对于AUTO_INCREMENTcd的字D,InnoDB中必d含只有该字段的烦引,?是在MyISAM表中Q可以和其他字段一起徏立联 合烦?/p>

更好和更快的auto_increment处理

如果你ؓ一个表指定AUTO_INCREMENT列,在数据词兔R的InnoDB表句柄包含一个名动增长计?器的计数器,它被用在列赋新倹{?p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">

自动增长计数 器仅被存储在d存中Q而不是存在磁盘上

关于该计器 的算法实玎ͼ请参?/p>

AUTO_INCREMENT??/strong>InnoDB?如何工作

表的具体行数select count(*) from table,MyISAM只要单的d保存好的行数Q注意的是,当count(*)语句包含 where条gӞ两种表的操作是一LInnoDB 中不 保存表的具体行数Q也是_执行select count(*) from tableӞInnoDB要扫描一遍整个表来计有多少?br />
improved in V5.6

?/strong>表锁提供行锁(locking on row level)Q提供与 Oracle cd一致的不加锁读?non-locking read in
SELECTs);

另外QInnoDB表的行锁也不是绝对的Q如果在?行一个SQL语句时MySQL不能定要扫描的范围QInnoDB表同样会锁全表,例如update table set num=1 where name like “%aaa%”
本文原出处ؓ www.dbahacker.com转蝲烦请保留 链接


crazycy 2014-03-06 11:09 发表评论
]]>
index study - 001http://www.aygfsteel.com/crazycy/archive/2014/01/22/409191.htmlcrazycycrazycyTue, 21 Jan 2014 19:02:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/22/409191.htmlhttp://www.aygfsteel.com/crazycy/comments/409191.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/22/409191.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/409191.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/409191.html
Source:http://programmerinterview.com/index.php/java-questions/java-introduction
How do database indexes work? And, how do indexes help? Provide a tutorial on database indexes.

Let’s start out our tutorial and explanation of why you would need a database index by going through a very simple example. Suppose that we have a database table called Employee with three columns – Employee_Name, Employee_Age, and Employee_Address. Assume that the Employee table has thousands of rows.

Now, let’s say that we want to run a query to find all the details of any employees who are named ‘Jesus’? So, we decide to run a simple query like this:

SELECT * FROM Employee  WHERE Employee_Name = 'Jesus'  

What would happen without an index on the table?

Once we run that query, what exactly goes on behind the scenes to find employees who are named Jesus? Well, the database software would literally have to look at every single row in the Employee table to see if the Employee_Name for that row is ‘Jesus’. And, because we want every row with the name ‘Jesus’ inside it, we can not just stop looking once we find just one row with the name ‘Jesus’, because there could be other rows with the name Jesus. So, every row up until the last row must be searched – which means thousands of rows in this scenario will have to be examined by the database to find the rows with the name ‘Jesus’. This is what is called a full table scan.

How a database index can help performance

You might be thinking that doing a full table scan sounds inefficient for something so simple – shouldn’t software be smarter? It’s almost like looking through the entire table with the human eye – very slow and not at all sleek. But, as you probably guessed by the title of this article, this is where indexes can help a great deal. The whole point of having an index is to speed up search queries by essentially cutting down the number of records/rows in a table that need to be examined.

What is an index?

So, what is an index? Well, an index is a data structure (most commonly a B- tree) that stores the values for a specific column in a table. An index is created on a column of atable. So, the key points to remember are that an index consists of column values from one table, and that those values are stored in a data structure. The index is a data structure – remember that.

What kind of data structure is an index?

B- trees are the most commonly used data structures for indexes. The reason B- trees are the most popular data structure for indexes is due to the fact that they are time efficient – because look-ups, deletions, and insertions can all be done in logarithmic time. And, another major reason B- trees are more commonly used is because the data that is stored inside the B- tree can be sorted. The RDBMS typically determines which data structure is actually used for an index. But, in some scenarios with certain RDBMS’s, you can actually specify which data structure you want your database to use when you create the index itself.

How does a hash table index work?

Hash tables are another data structure that you may see being used as indexes – these indexes are commonly referred to as hash indexes. The reason hash indexes are used is because hash tables are extremely efficient when it comes to just looking up values. So, queries that compare for equality to a string can retrieve values very fast if they use a hash index. For instance, the query we discussed earlier (SELECT * FROM Employee WHERE Employee_Name = ‘Jesus’) could benefit from a hash index created on the Employee_Name column. The way a hash index would work is that the column value will be the key into the hash table and the actual value mapped to that key would just be a pointer to the row data in the table. Since a hash table is basically an associative array, a typical entry would look something like “Jesus => 0×28939″, where 0×28939 is a reference to the table row where Jesus is stored in memory. Looking up a value like “Jesus” in a hash table index and getting back a reference to the row in memory is obviously a lot faster than scanning the table to find all the rows with a value of “Jesus” in the Employee_Name column.

The disadvantages of a hash index

Hash tables are not sorted data structures, and there are many types of queries which hash indexes can not even help with. For instance, suppose you want to find out all of the employees who are less than 40 years old. How could you do that with a hash table index? Well, it’s not possible because a hash table is only good for looking up key value pairs – which means queries that check for equality (like “WHERE name = ‘Jesus’”). What is implied in the key value mapping in a hash table is the concept that the keys of a hash table are not sorted or stored in any particular order. This is why hash indexes are usually not the default type of data structure used by database indexes – because they aren’t as flexible as B- trees when used as the index data structure. Also see: Binary trees versus Hash Tables.

What are some other types of indexes?

Indexes that use a R- tree data structure are commonly used to help with spatial problems. For instance, a query like “Find all of the Starbucks within 2 kilometers of me” would be the type of query that could show enhanced performance if the database table uses a R- tree index.

Another type of index is a bitmap index, which work well on columns that contain Boolean values (like true and false), but many instances of those values – basically columns with low selectivity.

How does an index improve performance?

Because an index is basically a data structure that is used to store column values, looking up those values becomes much faster. And, if an index is using the most commonly used data structure type – a B- tree – then the data structure is alsosorted. Having the column values be sorted can be a major performance enhancement – read on to find out why.

Let’s say that we create a B- tree index on the Employee_Name column This means that when we search for employees named “Jesus” using the SQL we showed earlier, then the entire Employee table does not have to be searched to find employees named “Jesus”. Instead, the database will use the index to find employees named Jesus, because the index will presumably be sorted alphabetically by the Employee’s name. And, because it is sorted, it means searching for a name is a lot faster because all names starting with a “J” will be right next to each other in the index! It’s also important to note that the index also stores pointers to the table row so that other column values can be retrieved – read on for more details on that.

What exactly is inside a database index?

So, now you know that a database index is created on a column in a table, and that the index stores the values in that specific column. But, it is important to understand that a database index does not store the values in the other columns of the same table. For example, if we create an index on the Employee_Name column, this means that the Employee_Age and Employee_Address column values are not also stored in the index. If we did just store all the other columns in the index, then it would be just like creating another copy of the entire table – which would take up way too much space and would be very inefficient.

An index also stores a pointer to the table row

So, the question is if the value that we are looking for is found in an index (like ‘Jesus’) , how does it find the other values that are in the same row (like the address of Jesus and his age)? Well, it’s quite simple – database indexes also store pointers to the corresponding rows in the table. A pointer is just a reference to a place in memory where the row data is stored on disk. So, in addition to the column value that is stored in the index, a pointer to the row in the table where that value lives is also stored in the index. This means that one of the values (or nodes) in the index for an Employee_Name could be something like (“Jesus”, 0×82829), where 0×82829 is the address on disk (the pointer) where the row data for “Jesus” is stored. Without that pointer all you would have is a single value, which would be meaningless because you would not be able to retrieve the other values in the same row – like the address and the age of an employee.

How does a database know when to use an index?

When a query like “SELECT * FROM Employee WHERE Employee_Name = ‘Jesus’ ” is run, the database will check to see if there is an index on the column(s) being queried. Assuming the Employee_Name column does have an index created on it, the database will have to decide whether it actually makes sense to use the index to find the values being searched – because there are some scenarios where it is actually less efficient to use the database index, and more efficient just to scan the entire table. Read this article to understand more about those scenarios: Selectivity in SQL.

Can you force the database to use an index on a query?

Generally, you will not tell the database when to actually use an index – that decision will be made by the database itself. Although it is worth noting that in most databases (like Oracle and MySQL), you can actually specify that you want the index to be used.

How to create an index in SQL:

Here’s what the actual SQL would look like to create an index on the Employee_Name column from our example earlier:CREATE INDEX name_index ON Employee (Employee_Name) 

How to create a multi-column index in SQL:

We could also create an index on two of the columns in the Employee table , as shown in this SQL:CREATE INDEX name_index ON Employee (Employee_Name, Employee_Age)

What is a good analogy for a database index?

A very good analogy is to think of a database index as an index in a book. If you have a book about dogs and you are looking for the section on Golden Retrievers, then why would you flip through the entire book – which is the equivalent of a full table scan in database terminology – when you can just go to the index at the back of the book, which will tell you the exact pages where you can find information on Golden Retrievers. Similarly, as a book index contains a page number, a database index contains a pointer to the row containing the value that you are searching for in your SQL.

What is the cost of having a database index?

So, what are some of the disadvantages of having a database index? Well, for one thing it takes up space – and the larger your table, the larger your index. Another performance hit with indexes is the fact that whenever you add, delete, or update rows in the corresponding table, the same operations will have to be done to your index. Remember that an index needs to contain the same up to the minute data as whatever is in the table column(s) that the index covers.

As a general rule, an index should only be created on a table if the data in the indexed column will be queried frequently.



crazycy 2014-01-22 03:02 发表评论
]]>
NoSQL学习Q九Q 2014q八大最热门的大数据工作http://www.aygfsteel.com/crazycy/archive/2014/01/19/409098.htmlcrazycycrazycySat, 18 Jan 2014 18:20:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409098.htmlhttp://www.aygfsteel.com/crazycy/comments/409098.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409098.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/409098.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/409098.html2014q八大最热门的大数据工作
作者:张霖 1?nbsp;16, 2014
http://www.ctocio.com/ccnews/14565.html
原文链接Q?文章来自ITl理|?/a>

大数据时代,数据q剩Qh才短~,来多的IT专业人士希望能够q入充满机遇的大数据领域Q但是,到底哪些具体的大数据专业岗位和h才最为吃香呢Qh力资源公司Kforceq日发布了一份报告根?a style="font-size: 1em; outline: 0px; padding: 0px; margin: 0px; border: 0px; text-decoration: none; vertical-align: baseline; color: #004276;">IT职业薪酬水^l出?014q最热门的十大大数据工作职位Q年薪)Q?/p>

一、ETL开发者(11-13万美元)
随着数据U类的不断增加,企业Ҏ据整合专业h才的需求越来越旺盛。ETL开发者与不同的数据来源和l织打交道,从不同的源头抽取数据Q{换ƈ导入数据仓库以满企业的需要?/span>

ETL软g行业相对成熟Q相兛_位的工作生命周期比较长,通常由内部员工和外包合同商之间通力完成。ETL人才在大数据时代炙手可热的原因之一是:在企业大数据应用的早期阶D,Hadoop只是Ih的ETL?br />
二、Hadoop开发者(15-17.5万美元)
Hadoop是基于Java的开源框Ӟ随着数据集规模不断增大,而传lBI的数据处理成本过高,企业?/span>Hadoop及相关的廉h数据处理技术如Hive、HBase、MapReduce、Pig{的需求将持箋增长。如今具备Hadoop框架l验的技术h员是最抢手的大数据人才?br />
三、大数据可视化工具开发者(15-17.5万美元)
量数据的分析是个大挑战Q?/span>新型数据可视化工具如SpotifreQQlikview和Tableau可以直观高效地展C数?/strong>。过去,数据可视化属于商业智能开发者类别,但是随着Hadoop的崛P数据可视化已l成了一独立的专业技能和岗位?br />
四、数据科学家Q?2-14万美元)
q去也称数据架构师,数据U学家是一个全新的工种Q能够将企业的数据和技术{化ؓ企业的商业h倹{数据科学家首先应当具备优秀的沟通技能,能够同时数据分析结果解释给IT部门和业务部门领对{?/span>

ȝ来说Q数据科学家是分析师、艺术家的合体,需要具备多U交叉科学和商业技能?br />
五、OLAP开发者(9.8-11.6万美元)
OLAP在线联机分析开发者,负责数据从关系型或非关pd数据源中抽取出来建立模型Q然后创建数据访问的用户界面Q提供高性能的预定义查询功能?/strong>

六、数据仓库一体机专家Q?.8-12.4万美元)
此类专家熟悉Teradata、Neteeza和Exadata{公司的大数据一体机。能够在q些一体机上完成数据集成、管理和性能优化{工作?br />
七、预分析开发者(10-13万美元)
营销部门l常使用预测分析预测用户行ؓ或锁定目标用戗预分析开发者有些场景看上有有些cM数据U学Ӟ卛_企业历史数据的基上通过假设来测试阈值ƈ预测未来的表现?br />
八、信息架构师Q?1.4-13.5万美元)
大数据重新激发了L据管理的热潮。充分开发利用企业数据ƈ支持决策需要非怸业的技能。信息架构师必须了解如何定义和存档关键元素,保以最有效的方式进行数据管理和利用。信息架构师的关键技能包括主数据理、业务知识和数据建模{?/span>



crazycy 2014-01-19 02:20 发表评论
]]>
NoSQL学习Q八Q 大数据要“落地”,q缺些什么?http://www.aygfsteel.com/crazycy/archive/2014/01/19/409097.htmlcrazycycrazycySat, 18 Jan 2014 17:59:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409097.htmlhttp://www.aygfsteel.com/crazycy/comments/409097.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409097.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/409097.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/409097.html大数据要“落地”Q还~Z什?br />http://www.pingwest.com/bigdata2/

大数?/span>是在2013q被用滥了的词汇Q但实际上,׃数据量缺失、大数据清洗和分析能力不I以及数据可视化瓶颈等问题Q?/span>大数?/span>一直未能迟q落地。伴随着基础设施的发展,意味着大数据的发展又走到新的一个新的界点。系lY件供应商Software AG?/span>Gagan MehraQ在Venturebeat|站阐述了他对于大数据接下来发展的认识,他认为更快地数据处理、更可靠的数据质量,以及更加l分的应用市场,是大数据2.0时代的重要特征?br />

更快的数据处理速度

׃数据量指数型增长Q?/span>对于数据的快速分析的需?/strong>已经变得比以往M时候都要迫切。几乎每家大数据厂商Q都惌兜售比别家处理速度更快的品?/span>Hadoop发布的新?/span>Hadoop 2.0 / YARNQ几乎能实时分析数据。而下一代大数据的计牵引框?/span>Apache SparkQ它的速度?/span>Hadoop?/span>100倍?/span>谷风险投资机构Andreessen HorowitzQ已l以1400万美元的hQ领投了一家以Apache SparkZ务核心的初创企业Databricks。不久前Q?/span>亚马逊也上线了实时流数据服务KinesisQ来帮助没有数据处理能力的公司解册一问题?br />

许多分析供应商都已经认识C数据处理速度的重要?/strong>Qƈ建立了能够每U处?/span>TB数据的品?/span>传感器数据分析、物联网在工业和消费U市场快速发展的势头Q驱动了q次变革?/strong>比如一家企业的传感器,能够每秒产生出数百次的事Ӟ实时处理q些数据隑ֺ很高。特别是当实时处理的传感器数据,Ȁ增到一?/span>5TB的时候,速度Q就成了ؓ关键的指标?/span>


同时Q尽数据存储成本已l篏q下降,但数据存储的费用q是不小的一W支出。部分商家相比存储完整数据流而言Q更們֐于保存过滤掉噪音的数据?br />

清洗垃圾数据

在本难以计数的数据量l以指数模型Ȁ增时Q对于数据质量的强化Q便摆上了许多数据供应商的议E?/span>换句话说Q在庞大数据面前Q即使计机能够高效的处理它们,但大量无用的垃圾数据Q只会给pȝ带来负担Qƈ增添存储、主机等讑֤成本?/span>q就需要数据处理过E中Q根据特定的规则和参敎ͼҎq数据流q行清洗和分析,q自动决{该d理哪些数据,q一切不再需要h工去q预?/span>

在这L环境下,如果选择了一个坏的数据,׃像病毒一P可能引发q箋的错误决{,甚至让企业蒙受经损失?/span>一个例子就是利用算法去q行股票交易Q以毫秒计数股票市场中,M一点小的差错,都有可能引发无法巨大的损失?/strong>

所以,数据质量已成为服务别协议(
service level agreementsQ最重要的参C一。无法屏蔽劣质的数据的供应商Q会因此被列入行业的黑名单,以及面严重的经处|?/span>B2B行业为早期数据质量的入局者,他们非常重视数据的质量,来保持商业运作时的稳定性。甚臻I许多企业计划为数据质量部|实时的警告pȝQ这些警告会被发送于负责相应问题的专员,׃们提供问题的解决Ҏ?br />

机器学习是另一w要保证数据质量的领域。机器学习系l部|在一个闭环的生态中Q通过模式分析与其他的数据分析技术,l化原来的数据质量规则。而高质量的数据,能够保证机器q行正确的行为模式分析?/span>


来多的基应用

大数据带来的变革Q得每一个h都想要利用它Q但技术上门槛又让许多Z得已只能充当一个看客。而应用将有助于h们去克服q一困难。在接下来的几年中,我们会看到成千上万的解?/span>某一垂直领域的专业应?/strong>Q以应对来自各行各业的大数据挑战?br />

目前Q已l小有成q数据分析公司包括eHarmony?/span> Roambi?/span> Climate Corporation{等。未来,甚至许多企业,既不用依赖特定基讑֤Q也不要雇䄦专业的数据科学家Q就能受益于对大数据分析利用?br />

比如Q一些应用将从各U渠道,攉兌的客h据,以更好地了解客户的需求。从而企业能够ؓ特定的目标客P提供特定需求的产品Q更有针Ҏ地赚到钱。当q些应用走进Z日常的吃喝玩乐、医疗保健等领域Q生zM会因此而更好?/span>

 



crazycy 2014-01-19 01:59 发表评论
]]>
NoSQL学习Q七QHadoop是数据仓库的l结者吗?http://www.aygfsteel.com/crazycy/archive/2014/01/19/409096.htmlcrazycycrazycySat, 18 Jan 2014 17:27:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409096.htmlhttp://www.aygfsteel.com/crazycy/comments/409096.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/19/409096.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/409096.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/409096.htmlHadoop是数据仓库的l结者吗?
2014q?1?3日 | 作者:邚w~译 | 来源Q网界网
http://news.cnw.com.cn/news-international/htm2014/20140113_289451.shtml

?/span>CNW.com.cn独家译稿?/span>在过Mq_Hadoop生态系l已l大范围扩展Q很多主要IT供应商都推出了Hadoopq接器,以增强Hadoop的顶层架构或是供应商自己使用的Hadoop发行版。鉴于Hadoop的部|率呈指数的增长,以及其生态系l不断地深入而广泛地发展Q我们很想知道Hadoop的崛h否会D传统数据仓库解决Ҏ的终l呢?/span>

我们也可以将q个问题攑ֈ一个更大的环境中去讨论Q在何种E度上,大数据会改变传统数据分析的环?/span>?

数据仓库是技术和软g套gQ它能够从操作系l收集数据,q将q些数据整合Qƈl一C央数据库中,然后Ҏ据A表盘上指标进行分析、可视化和追t关键性能处理?/span>

数据仓库?/span>Hadoop之间的主要区别是Q数据仓库通常部v在单个关pL据库中,而这个数据库则vC央存储的作用。相比之下,Hadoop及其Hadoop文gpȝ是跨多个机器Qƈ用来处理量数据的,而这是Q何单台机器都达不到的能力?/span>

此外Q?/span>Hadoop生态系l包括构建在Hadoop核心之上的数据仓库层/服务Q而Hadoop上层服务包括SQL(Presto)、SQL-Like(Hive)和NoSQL(Hbase)cd的数据存?/span>。相比之下,在过ȝ十年中,大型数据仓库转移C用自定义多处理器讑֤来扩展数据量Q像Netezza(被IBM收购)和Teradata所提供的数据仓库。然而,q些讑֤都非常昂贵,大多C企业都负担不v?/span>

在这U背景下Q我们很自然地要问:Hadoop是否是数据仓库的l结?

Z回答q个问题Q我们需要将数据仓库技术与数据仓库部v分开来看?/span>Hadoop(和NoSQL数据库的出现)预C着数据仓库讑֤和传l数据仓库单一数据库部|的消亡?/span>

而在q方面就有过实例?/span>Hadoop供应商Cloudera其q_作ؓ“企业数据枢纽”Q这在本质上传l数据管理解x案的U_了需求。ReadWrite.com在最q发表的一题?#8220;Z么专有大数据技术没有希望与Hadoop竞争”的文章中也发表了cM的看法。同样地Q最q一华街日报文章描述了Hadoop如何挑战甲骨文和Teradata?/span>

Hadoop或NoSQL生态系l仍l发展。很多大数据环境开始选择NoSQL、SQL甚至是NewSQL数据仓库的؜合方法。此外,MapReduceq行处理引擎也有变化和改q,例如Apache的Spark目。虽然这个故事还q远没有l束Q?strong>但可以说Q传l的单一服务器关pd数据库或数据库设备ƈ不是大数据或数据仓储的未?/strong>?/span>

另一斚wQ数据仓库技?/span>(包括提取—转换—?#8212;加蝲、三l徏模和商业)会应用到新的Hadoop/NoSQL环境。此外,q些技术也变w来支持更多的؜合环境。主要原则是因ؓq不是所有数据都是^{的Q所以ITl理们应该选择数据存储和访问机制来适应数据的用。؜合环境将包括关键价值存储、关pd数据库、图形存储、文档存储、柱状存储、XML数据库、元数据目录{等?/span>

正如你所看到的,qƈ不是一个简单的问题Q也不可能简单地得出一个答案。然而,一般情况下Q虽然大数据在未来五q内会改变数据仓库的部|Ԍ但它不会D数据仓库的概念和做法q时?/span>

对于向数据仓库投入巨资的联邦政府q意味着什么呢?

首先Q当现有数据仓库的容量不够时Q数据仓库将被{UdZHadoop、多机器或云托管的解x案。其ơ,企业q不会选择“放之四v而皆?#8221;的做法,而会目光{向适合其企业内部数据容量的混合存储Ҏ。(邚w~译Q?/span>

 



crazycy 2014-01-19 01:27 发表评论
]]>
NoSQL学习Q六Q 2014q大数据分析势展望(?http://www.aygfsteel.com/crazycy/archive/2014/01/18/409091.htmlcrazycycrazycySat, 18 Jan 2014 13:51:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/18/409091.htmlhttp://www.aygfsteel.com/crazycy/comments/409091.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/18/409091.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/409091.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/409091.html2014q大数据分析势展望
Posted on 2014q?1??nbsp;by DinK in 行业资讯 
http://www.199it.com/archives/185758.html

市场研究公司IDC预测Q?015q大数据市场规模从2010q的32亿美元增长到170亿美元,复合q增长率?0%。大数据是一个庞大的新的领域Q其中的数据集可以增长的非常庞大Q以至于使用传统的数据库理工具也很隑֤理。处理这U问题所需要的新工兗框架、硬件、Y件和服务是一个巨大的市场Z。随着企业用户来多地需要连l不断地讉K数据Q好的大数据工具集将以最低的成本和接q实时的速度提供可׾~的、高性能的分析。通过分析q种数据Q企业可得到更大的智能以及竞争优ѝ下面是Hadoop和大数据专业厂商MapR共同创始人和首席执行官约?#183;施罗PJohn SchroederQ对2014大数据市场的预测?/span>

1. SQL拥有大数据的最大潜?/span>

用于 HadoopQ分布式计算Q的SQL的发展能够让商业分析师利用自q技能和选择的SQL工具执行大数据项目。开发h员可以选择Hive、Drill?Impala{Apache目Q以及选择Hadapt、HAWQ和Splice Machine{公司的专有技术?/span>

2. 管如此 SQLq面临挑?/span>

SQL需要数据结构。而集中的l构化数据可引v延迟q且需要h工管理。SQLq限制分析类型。过分强调SQLgq机构全面利用其数据价值的努力和gq反应?/span>

3. w䆾识别是主要的数据安全问题

随着HadoopQ分布式计算Q中提供的接入控制能力的猛烈dQ机构迅速认识到U\Un份识别是必要的基。没有充分的w䆾识别QQ何更高的控刉很容易被l过Q妨预定的安全计划?/span>

4. 数据错误变成学习Z

2014q机构将出现许多数据错误。数据错误将表明基础的来源系l的问题吗?数据错误是在下游分析中出现偏差导致的数据提取问题吗?数据错误表明定义差异或者缺跨部门和业务部门的一致性吗Q?014q将看到解决数据异常问题?/span>

5. 出现可运行的Hadoop

2014q将看到Hadoop在各个行业中的生产部|显著增加。这显C出Hadoop在运营中的实力。在那里Q生产应用与分析l合在一赯够提供可以衡量的商业优势Q如在客户化零售、诈骗检和试验传感器数据进行规范的l护{应用中提供q些优势?/span>

6. 更多的数据仓库将部v企业数据中心

数据中心把数据提取处理和数据从企业数据仓库卸载到Hadoop。作Z个核心的中心企业中心Q数据中心要便宜10倍,能够寚w外的处理或者新的应用进行更多的分析?/span>

7. 新的以数据ؓ中心的应用将成ؓ强制性的

利用大数据的能力在2014q成为竞争的武器。更多的公司用大数据和Hadoop准确地针对个人消费者的偏爱q逐赚qq加销售和交叉销售的ZQ更好地~解风险以及减少生和开销成本?/span>

8. 数据成ؓ数据中心的核?/span>

机构从开发者过渡到大数据计划中?/span>IT部门越来越多地担负定义支持多种应用的数据基设施的Q务,把重炚w中在部v、处理和保护一个机构的核心资所需要的基础设施斚w?/span>

9. 搜烦成为非l构化的查询语言

2013q有大量的用于Hadoop的SQL计划?014q将是这U非l构化查询语a成ؓ重点的一q。把搜烦集成到Hadoopؓ查找重要信息的企业用h供一U简单和直观的方法。搜索引擎还是包括推荐引擎在内的许多发现和分析应用的核心?/span>

10. Hadoop获得地?/span>

Hadoopl取代其它IT开支,颠覆企业数据仓库和企业存储。例如,甲骨文的主要营收目标在过ȝ10个季度里?个季度没有实现。Teradata在过ȝ5个季度有4个季度没有实现营收和利润目标?/span>

11. Hadoop仍需要帮助才能成Z应?/span>

更多的机构认识到Apache Hadoop本nq没有准备好在企业应用。Apache Hadoop不是为系l管理或者灾难恢复等l一企业IT程设计的。企业将l箋推进混合的解x案,把架构技术创CApache Hadoop的开源Y件结合在一赗?/span>

英文http://www.cio.com.au/slideshow/534054/pictures_12_big_data_predictions_2014/?image=3

译文http://www.csdn.net/article/2013-12-25/2817926-pictures-12-big-data-predictions-2014
2014?2个大数据势QHadoopl箋升温QR进入主?/div>

当下Q?/span>大数?/span>已成?/span>2013q最火的技术词汇之一Q而在q去一q_q个市场的增速和改变也不可谓不大。同Ӟ我们q看CHadoop及其生态系l的使用门槛从顶技术h才到数据U学家的改变。越来越多的企业拥抱大数据技术,q将其运用到生环境中。那么,?/span>2014q大数据的发展趋势又会如何,q里不妨看一下来?/span>CIO?/span>12w:

1. Z不再止步于大数据的谈?/span> 

2014q_大数据止于说的情况将发生改变Qh们将致力于从中获益,所有大数据的炒作也?/span>烟消云散。从Gainsight了解刎ͼ大数据本w也成为桌面上的筹码,Gainsight在其IaaSq_中利用大数据分析被其UC?/span>“customer success management”的服务?/span>Gainsight认ؓQ在2014q_每家云应用程序提供商都将会让其后端基设施支持大数据?/span>


2. Hadoop
成Z业的关键lg
Hadoop
普及,大数据也不会再l止步于云服务?/span>Alteryx认ؓQ?/span>2014q_Hadoop的适用场景超批处理和存储,成Z业数据架构中通用的核心组Ӟq意味着数据分析l成为大数据的首要用例?/span>


3.
企业更加钟情于用户数据
?/span>Gainsight了解刎ͼ各个机构对用户数据充满热情Q企业将充分利用客户与其在线产品或服务交互生的数据Qƈ从中获取价倹{ؓ了实现这点,数据分析能力比BI团队更受重视Qؓ企业提供更多的h倹{?/span>


4.
大数据玩转市场决{?/span>
Alteryx
认ؓQ在2014q_大数据将首次正式登陆市场营销Q用于市销的大数据技术将在这一q扮演重要角?/span>——影响着q告、品推销和消费者行为,World Cup?/span>Winter Olympics是其最大的舞台?/span>


5.
量的数据将越数据U学家的意识
lteryx
认ؓQ新型的数据分析需求将越人力可ؓQ有些情况下大数据技术将堪比成千上万的数据科学家。该公司预测Q这会毫无疑问的拉低数据科学家薪酬?/span>


6.
物联|将q军|络
IEEE
的专业协会认为,2014q_可识别事物将无缝的连接到信息|络Q实现真正意义上?/span>Web of Things?/span>The Web of Things会充分利用Ud讑֤和传感器的监控能力,增强现实世界中的物体?/span>Web副本之间的协同性?/span>

The Web of Things会生成大量与现实世界相关的数据Q因而会需求智能化的解x案在现实世界与相对应的数字世界资源之间赋予连接性、网际互q和相关性?/span>


7.
从大数据到v量数?/span>
数据的体U、速度和类型(volume?/span>velocity?/span>varietyQ在2014q将会l呈指数U增长,因此需要更单的分析工具来驾驭这?/span>数据z流?/span>

IEEE
不止?/span>3?/span>V让大数据成了非常难以制服的老虎Q数据科学家及行业所需单工具也是个NQ许多行业尚无独立提取数据h值的能力。当前已出现的v量数据时代更需求数据管理和分析上新的范式和实践?/span>2014q_q个领域上演群雄争霸?/span>


8. R
语言取代传l?/span>SAS解决Ҏ
Alteryx
认ؓQ基?/span>R~程语言的分析将数据U学?/span>御用模式Q这U分析在2014q将成ؓLQ将替代传统?/span>SAS?/span>SPSS模式?/span>Alteryx说道Q?/span>200万用户和300万的分析师都在寻找更好的解决ҎQ?/span>R恰逢其时?/span>


9. Hadoop
增加实时特?/span>
SQL-on-Hadoop
供应?/span>Splice Machine共同创始人兼CEO Monte Zweben指出Q未?/span>1q徏立在Hadoopq_上的交互式应用程序将呈爆发式增长Q其中包?/span>Web应用、移动应用和C交应用Qh们可以与之进行实时的交互?/span>

Zweben说道Q?/span>“2014带来实时大数据应用E序q_Q企业将不会只能像当下一样分析历史数据,你将有能力分?/span>5分钟Q甚x1分钟之内的数据;企业拥有交互式应用E序Q以便实时的制定决策?/span>


10. Hadoop
得C业强化
Splice Machine
?/span>Zweben_毋庸|疑Q?/span>Hadoop是个了不Lq_Q但是仍然有许多工作要做?/span>

他认为,?/span>2014Q你看?/span>Hadoop向安全、运营管理、资源管理及多站点响应方向发展?/span>Zweben补充道:你将看到所有的企业U需求,我认些将是未来主要的焦点?/span>


11.  2014
q底Q至有一?/span>NoSQL IPO
大数据及云环境安全解x?/span>Gazzang董事长兼CEO Larry Warnock预测Q在2014Q至有一?/span>Hadoop或?/span>NoSQL供应商会IPOQ这标志着大数据^台已被广泛认可?/span>

Warnock说道Q?/span>我不会去预测哪家?/span>IPOQ但是至会有一?/span>Hadoop?/span>NoSQL供应?/span>IPO。通过Wikibon了解刎ͼ?/span>2012q_NoSQL软g和服务创造了2.86亿美元的E收Q而在2017q_q个数据被预ؓ18.25ѝ商不断增长的企业需求推动,他们需要灵zR可扩展及负担得L数据理解决ҎQؓ新时代的云及大数据设计?/span>


12.
一个新的分析堆栈将诞生
Alteryx
预测Q?/span>2014q_出C个新的数据及分析堆栈Qؓ数据库、分析、可视化提供新的解决ҎQ这直接威胁到传统的供应商巨头Q而这些供应商也会在匆忙中推出新的解决Ҏ?/span>

 



crazycy 2014-01-18 21:51 发表评论
]]>NoSQL学习Q五QCassandra vs MongoDB vs CouchDB vs Redis vs Riak vs HBase vs Couchbase vs Neo4j vs Hypertable vs ElasticSearch vs Accumulo vs VoltDB vs Scalaris comparisonhttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408883.htmlcrazycycrazycyMon, 13 Jan 2014 17:34:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408883.htmlhttp://www.aygfsteel.com/crazycy/comments/408883.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408883.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/408883.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/408883.html阅读全文

crazycy 2014-01-14 01:34 发表评论
]]>
NoSQL非关pd数据库学习(四)q样Ҏ下HBase, Memcached, MongoDB, Redis和Solrhttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408880.htmlcrazycycrazycyMon, 13 Jan 2014 16:27:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408880.htmlhttp://www.aygfsteel.com/crazycy/comments/408880.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/14/408880.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/408880.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/408880.html阅读全文

crazycy 2014-01-14 00:27 发表评论
]]>
NoSQL非关pd数据库学习(三)NoSQL与RDBMSQ何时用,何时不?/title><link>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408845.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 04:12:00 GMT</pubDate><guid>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408845.html</guid><wfw:comment>http://www.aygfsteel.com/crazycy/comments/408845.html</wfw:comment><comments>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408845.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/crazycy/comments/commentRss/408845.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/crazycy/services/trackbacks/408845.html</trackback:ping><description><![CDATA[     摘要: NoSQL数据库面临的挑战NoSQL vs RDBMS: Why and why not to use NoSQL over RDBMS?  Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Naresh Kumar3 J...  <a href='http://www.aygfsteel.com/crazycy/archive/2014/01/13/408845.html'>阅读全文</a><img src ="http://www.aygfsteel.com/crazycy/aggbug/408845.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/crazycy/" target="_blank">crazycy</a> 2014-01-13 12:12 <a href="http://www.aygfsteel.com/crazycy/archive/2014/01/13/408845.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL非关pd数据库学习(二)http://www.aygfsteel.com/crazycy/archive/2014/01/13/408844.htmlcrazycycrazycyMon, 13 Jan 2014 04:03:00 GMThttp://www.aygfsteel.com/crazycy/archive/2014/01/13/408844.htmlhttp://www.aygfsteel.com/crazycy/comments/408844.htmlhttp://www.aygfsteel.com/crazycy/archive/2014/01/13/408844.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/408844.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/408844.htmlGartner分析?/span>Merv Adrian?/span>Twitter?/span>RT了一条关?/span>NoSQL数据库评选的消息Q他认ؓq就像是在对比你更喜Ƣ苹果、鸡Nq是西兰花,它们都有不同的应用场景,ҎNoSQL产品是没有意义的。比?/span>MongoDB?/span>Cassandra没有什么可比性,它们的共同点只是都叫?/strong>NoSQL数据库而已Q它们的应用场景非常不同?/span>

 

下面q是Ҏ学习Q对现在比较热门的MangoDB和Memcached以及Redis做个单的学习Q?/span>

MangoDB?/span>(document database, 盘?/span>)
a. Z盘的数据库Q只是缓存热Ҏ据在内存中?/span>
b. 文档型的非关pd数据库,
    优势是查询功能强大,可存储v量数据?/span>
c. 可替?/span>MySQL{关pd数据?/span>;
    在内存够的情况下,d性能不错Q可省去Cacheq一?br />

Memcached?/span>Redis?/span>(key value store, 内存?/span>)
a.内存型数据库Q数据保存在内存中,通过TCP直接存取Q?/span> 或者说是全内存Cache?/span>
   优势是速度快,q发高,~点是数据类型有限,查询功能不强Q一般做~存?/span>
b. Key Value Store
c. 全内?br />

Memcached vs Redis
a. 都是Key Vale, Memory Cache
b. Memecahced?multiple-thread; 适合多核CPU的应用?/span>
    Redis?single-thread.
    如果再多数据l构基础上支持多U程Q加锁可能是个问?/span>Q待深入学习验证Q?/strong>?br /> c. Redish持久化机Ӟ可以定期内存的数据持久化到盘?/span>
d. Redis支持的数据类型更?/span>
e. Redis 具备binlog功能Q将所有操作写入日志,以便redis出现故障Ӟ可通过binlogq行恢复?/span>
f. Redis支持Virtual MemoryQ可限定内存大小Q当数据出阀|通过cMLRU的算法将最不常用的数据保存到硬盘的面问题中?/span>

 



crazycy 2014-01-13 12:03 发表评论
]]>
NoSQL非关pd数据库学习(一Q?/title><link>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408842.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 03:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408842.html</guid><wfw:comment>http://www.aygfsteel.com/crazycy/comments/408842.html</wfw:comment><comments>http://www.aygfsteel.com/crazycy/archive/2014/01/13/408842.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/crazycy/comments/commentRss/408842.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/crazycy/services/trackbacks/408842.html</trackback:ping><description><![CDATA[     摘要: ?008q的时候,我还是只知道DB2, Oracle, MS SQLServer, Sybase, MySQL, PostgreSQL,  Firebird{主商业或者开源数据库。当汲取知识于网l之际,H然发现很多新的名词D而出Q什?SQLite, Memcached,  FastDB, MongoDB, Solr, Redis, HBase,  Cass...  <a href='http://www.aygfsteel.com/crazycy/archive/2014/01/13/408842.html'>阅读全文</a><img src ="http://www.aygfsteel.com/crazycy/aggbug/408842.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/crazycy/" target="_blank">crazycy</a> 2014-01-13 11:53 <a href="http://www.aygfsteel.com/crazycy/archive/2014/01/13/408842.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sqlserver: Invalid use of a side-effecting operator within a function (Print/Raiserror)http://www.aygfsteel.com/crazycy/archive/2013/10/25/405643.htmlcrazycycrazycyFri, 25 Oct 2013 10:24:00 GMThttp://www.aygfsteel.com/crazycy/archive/2013/10/25/405643.htmlhttp://www.aygfsteel.com/crazycy/comments/405643.htmlhttp://www.aygfsteel.com/crazycy/archive/2013/10/25/405643.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/405643.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/405643.html
使用
raiserror('enter this line', 16, -1) with log
print('enter this line')

分别遇到?br />Invalid use of a side-effecting operator 'Print' within a function
Invalid use of a side-effecting operator 'Raiserror' within a function

原来Q在函数中用DMLq真不能太随意,SELECT可以QUPDATE/DELTE/INSERTq真不可以?br />|上google了下Q还真是不少cM的案?br />1. Functions are used to return data: scalar-value or table-value.
2. 
Invalid use of side-effecting or time-dependent operator in ‘newid’ within a function.
It states that the use of side-effecting and time-dependent operators is not allowed within a function. 


Side-Effecting Operators
A side-effecting operator is basically what it says.  
It is an operator that affects anything outside the function.  
This could be seen when trying to create an object or insert or update a table.  

Functions should be self-contained.  
They can use data from the database, but should not affect data in the database.  
In other words, functions should be read-only.

There is a list of side-effecting operators, which include INSERT, CREATE, UPDATE, OPEN, CLOSE, DELETE, SELECT … INTO, and more.  
You cannot use these inside a function.  
If you do, you will receive a slightly different message.  The message will not mention time-dependent operators.  It will look like this.
Msg 443, Level 16, State 15, Procedure FN_TEST, Line 9
Invalid use of a side-effecting operator ‘INSERT’ within a function. 

To get around some of the side-effecting operator rules shown by Msg 443, we can use a table variable.  
Below is an example on a table valued function.  It returns a table variable.  
In the function we insert, update, and delete from the table variable.  
You cannot create a temp table, but table variables are OK.

CREATE FUNCTION FN_TEST()
RETURNS @table TABLE (
 i int,
 j int)
AS
BEGIN
 
 INSERT INTO @table
 SELECT 1, 0
 UNION ALL
 SELECT 2, 2
  
 UPDATE @table
 SET j = 1
  
 DELETE @table
 WHERE i = 1
  
 RETURN
  
END

If you try this function yourself, you will see that it compiles and executes with no problem. 
Operators used on table variables are not considered side-effecting operators.

Time-Dependent Operators
You will also receive Msg 443 if you use time-dependent operators in a function.  
Time-dependent operators are those which return a value based on the time.  
This include, but are not limited to GETDATE(), SYSDATETIME(), NEWID(), and RAND().  
This is because functions should to return the same value when provided with the same set of inputs.  
Since these functions return a different value each time, they are not allowed. 
There is one solution to part of this problem.  If you wish to use a date or an id, you can provide it to the function.  
You could pass NEWID() or GETDATE() as the value of a parameter sent to the function.  
If you need to use time-dependent operators multiple times, you can’t use a function.


crazycy 2013-10-25 18:24 发表评论
]]>
The database principal owns a schema in the database, and cannot be droppedhttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401471.htmlcrazycycrazycyThu, 11 Jul 2013 09:34:00 GMThttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401471.htmlhttp://www.aygfsteel.com/crazycy/comments/401471.htmlhttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401471.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/401471.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/401471.htmlwhile delete this user, an error encounter like this: The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)
 
but use the below script, I successfully removed;
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('YourUserID');

find all the schemas to be removed
ALTER AUTHORIZATION ON SCHEMA::YourSchemaName TO dbo;


crazycy 2013-07-11 17:34 发表评论
]]>
SQLServer Create Login/Create User/Grant Privildges to a userNamehttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401448.htmlcrazycycrazycyThu, 11 Jul 2013 04:52:00 GMThttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401448.htmlhttp://www.aygfsteel.com/crazycy/comments/401448.htmlhttp://www.aygfsteel.com/crazycy/archive/2013/07/11/401448.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/401448.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/401448.htmlabove refer to uri

If you want to give your user all read permissions, you could use:

EXEC sp_addrolemember N'db_datareader', N'your-user-name'

That adds the default db_datareader role (read permission on all tables) to that user.

There's also a db_datawriter role - which gives your user all WRITE permissions (INSERT, UPDATE, DELETE) on all tables:

EXEC sp_addrolemember N'db_datawriter', N'your-user-name'

 

If you need to be more granular, you can use the GRANT command:

GRANT SELECT, INSERT, UPDATE ON dbo.YourTable TO YourUserName
GRANT SELECT, INSERT ON dbo.YourTable2 TO YourUserName
GRANT SELECT, DELETE ON dbo.YourTable3 TO YourUserName

and so forth - you can granularly give SELECT, INSERT, UPDATE, DELETE permission on specific tables. 



by me:

If you want to give your user permissions to execute a procedure, you could use:

GRANT EXECUTE ON OBJECT::dbo.your_procedure_name TO N'your-user-name';

below is a full step to create a user db_user, and give him permissions to execute a procedure to a table db_tableABC and a procedureproc_get_price_data; assuming the user's loginName is your_user_login_name

--add a db engine login

IF NOT EXISTS(SELECT name FROM sys.server_principals WHERE name='{your_domain\}your_user_login_name')
CREATE LOGIN [{your_domain\}your_user_login_name] WITH PASSWORD='your_user_password'
, DEFAULT_DATABASE = TestDB;

--add a user to current database
use TestDB;
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name='db_user')
CREATE USER [db_user] FOR LOGIN [{your_domain\}your_user_login_name];

--grant
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.db_tableABC TO your_user;
GRANT EXECUTE ON OBJECT::dbo.proc_get_price_data TO your_user;

e.g.
assuming a user named domain123\admin1 can access a database;

IF EXISTS(SELECT name FROM sys.server_principals WHERE name = '[domain123\admin1]')
BEGIN   
   IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = 'admin1')        
   BEGIN             
        CREATE USER [admin1] FOR LOGIN [domain123\admin1];                   
   END
   GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.
db_tableABC TO admin1;  
   GRANT EXECUTE ON OBJECT::dbo.GET_PRICE_DATA TO admin1;
END



crazycy 2013-07-11 12:52 发表评论
]]>
SQL2008R2: A network error occurred while attempting to read from the file C:..\..\sqlncli.msihttp://www.aygfsteel.com/crazycy/archive/2013/06/19/400752.htmlcrazycycrazycyWed, 19 Jun 2013 14:24:00 GMThttp://www.aygfsteel.com/crazycy/archive/2013/06/19/400752.htmlhttp://www.aygfsteel.com/crazycy/comments/400752.htmlhttp://www.aygfsteel.com/crazycy/archive/2013/06/19/400752.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/400752.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/400752.html
H然遭遇了从来没有的问题Q?span style="font-size: 14px;">A network error occurred while attempting to read from the file C:..\..\sqlncli.msi  如图?br />
因ؓ距离下班旉很近了,很着急也很恼火,捣鼓来捣鼓去Q最后打开了控刉板,一看,妈呀好多SQL Server的东东,挨着删除吧。。。居然就可以安装了了。。。?br />
最l发现如果Q?SQLNCLI或者Native Client存在了,׃出现q个问题?br />Microsoft大哥居然弄了q么黑的一招。。?br />
同时看到有h遭遇了类似的悲剧Q?br />
Finally got the Client Tools and Mangement Studio installed. What I did was remove Microsoft SQL Server 2008 Native Client in Add or Remove Programs (before I was just trying to uninstall Microsoft SQL Server 2008 and it failed). After Native Client was removed, I reinstalled client tools and mangement studio from a dvd (was mounting the iso before). Everything installed perfectly.

q个释的更多Q?br />
The cause of the error
I wondered what was different between my clean test-VM and my server that I was now attempting to install SQL-SERVER 2008 R2 Client Tools and SSMS onto.  Both were 64-Bit OS's and same setup, etc., but one was a clean VM.  This got me thinking

I had PREVIOUSLY installed JUST the SQLNCLI (SQL-Server Native Client) for SQL 2008 R2 onto my physical system, in order to test application connectivity to a SQL2008R2 database.  So, could that be it!?  YES!  After uninstalling any previously installed SQLNCLI applications, and re-running the SQL-Server installer, amazingly my "network errors" were gone and the installation was fixed!  

Microsoft: GIVE MEANINGFUL ERROR MESSAGES!  All the installer had to do was say that "previous installations of SQLNCLI / native client exist and must be removed before installing" in fact, the PREREQUISITES-CHECK SHOULD HAVE TESTED FOR THIS if it can cause a total failure to install!  


crazycy 2013-06-19 22:24 发表评论
]]>
数据库触发器Trigger或者存储过EProcedure的调试技?/title><link>http://www.aygfsteel.com/crazycy/archive/2013/04/10/397659.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Wed, 10 Apr 2013 12:05:00 GMT</pubDate><guid>http://www.aygfsteel.com/crazycy/archive/2013/04/10/397659.html</guid><wfw:comment>http://www.aygfsteel.com/crazycy/comments/397659.html</wfw:comment><comments>http://www.aygfsteel.com/crazycy/archive/2013/04/10/397659.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/crazycy/comments/commentRss/397659.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/crazycy/services/trackbacks/397659.html</trackback:ping><description><![CDATA[use Print<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">PRINT</span> <span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">testing----</span><span style="color: #FF0000; ">'</span> <span style="color: #0000FF; ">WAITFOR</span> DELAY <span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">00:00:05</span><span style="color: #FF0000; ">'</span>;</div>E序中调用这个procedure或者触发这个triggerQjava控制台根本没有这个输出;<br />很生气,后果很严重的让时间飞逝?br /><br />|上众多大拿推荐使用RaiserrorQ于?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">raiserror</span> (<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test raiserror 1---</span><span style="color: #FF0000; ">'</span>, <span style="color: #800000; font-weight: bold; ">10</span>, <span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>) <span style="color: #0000FF; ">with</span> <span style="color: #ff00ff;">log</span><br /><br /><span style="color: #0000FF; ">raiserror</span> (<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test raiserror 2---</span><span style="color: #FF0000; ">'</span>, <span style="color: #800000; font-weight: bold; ">10</span>, <span style="color: #800000; font-weight: bold; ">1</span>) <span style="color: #0000FF; ">with</span> nowait</div>E序中调用这个procedure或者触发这个triggerQjava控制台根本没有这个输出;<br />很生气,后果很严重的让时间飞逝?br /><br />于是Q很无语胡ؕ的测试:<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><span style="color: #0000FF; ">raiserror</span> (<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test raiserror 3---</span><span style="color: #FF0000; ">'</span>, <span style="color: #800000; font-weight: bold; ">16</span>,<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>) <span style="color: #0000FF; ">with</span> <span style="color: #FF00FF; ">log</span>;<br /><span style="color: #0000FF; ">raiserror</span> (<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test raiserror 4---</span><span style="color: #FF0000; ">'</span>, <span style="color: #800000; font-weight: bold; ">16</span>,<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>) <span style="color: #0000FF; ">with</span> nowait;</div>M一条都输出q且让程序回滚,很好很好<br /><br />我得扑ֈq个原因Q?br />ȝ<a >MSDN</a>吧:<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> A <span style="color: #0000FF; ">RAISERROR</span> severity <span style="color: #0000FF; ">of</span> <span style="color: #800000; font-weight: bold; ">11</span> <span style="color: #0000FF; ">to</span> <span style="color: #800000; font-weight: bold; ">19</span> executed <span style="color: #808080; ">in</span> the TRY block <span style="color: #0000FF; ">of</span> a TRY…CATCH construct causes control <span style="color: #0000FF; ">to</span> transfer <span style="color: #0000FF; ">to</span> the associated CATCH block. Specify a severity <span style="color: #0000FF; ">of</span> <span style="color: #800000; font-weight: bold; ">10</span> <span style="color: #808080; ">or</span> <span style="color: #FF00FF; ">lower</span> <span style="color: #0000FF; ">to</span> <span style="color: #0000FF; ">return</span> messages using <span style="color: #0000FF; ">RAISERROR</span> without invoking a CATCH block. <span style="color: #0000FF; ">PRINT</span> does <span style="color: #808080; ">not</span> transfer control <span style="color: #0000FF; ">to</span> a CATCH block.</div>好吧Q?0以上的数字才会强q它工作?br /><br />但是呢,Z不抛错误Q我们可以做以下2U方案:<br />Ҏ一Q?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->建立tmp表,利用insert保存你要的结?/div>Ҏ二:<br />不知道try catch是不是能帮上忙,q在下回测试吧?br /><br />f<div></div><img src ="http://www.aygfsteel.com/crazycy/aggbug/397659.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/crazycy/" target="_blank">crazycy</a> 2013-04-10 20:05 <a href="http://www.aygfsteel.com/crazycy/archive/2013/04/10/397659.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server: SYSOBJECTShttp://www.aygfsteel.com/crazycy/archive/2012/12/31/393651.htmlcrazycycrazycyMon, 31 Dec 2012 05:04:00 GMThttp://www.aygfsteel.com/crazycy/archive/2012/12/31/393651.htmlhttp://www.aygfsteel.com/crazycy/comments/393651.htmlhttp://www.aygfsteel.com/crazycy/archive/2012/12/31/393651.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/393651.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/393651.htmlUse OBJECTPROPERTY To Generate A List Of Object Types
How do you query the sysobjects system table and get the object type back for every single object
You can use the type and xtype columns, these contain the following data

xtype
Object type. Can be one of these object types:
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = Inlined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure


type
Object type. Can be one of these values:
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
FN = Scalar function
IF = Inlined table-function
K = PRIMARY KEY or UNIQUE constraint
L = Log
P = Stored procedure
R = Rule
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
V = View
X = Extended stored procedure

Or you can use OBJECTPROPERTY. OBJECTPROPERTY is better in my opinion because you can see right away what you are looking for
For example OBJECTPROPERTY ( id , 'IsUserTable' ) is much easier to understand than type = 'u'

Bu using CASE with OBJECTPROPERTY we can generate a nice report

SELECT name,CASE
WHEN OBJECTPROPERTY ( id , 'IsSystemTable' ) =1 THEN 'System Table'
WHEN OBJECTPROPERTY ( id , 'IsProcedure' ) =1 THEN 'Procedure' 
WHEN OBJECTPROPERTY ( id , 'IsPrimaryKey' ) =1 THEN 'Primary Key' 
WHEN OBJECTPROPERTY ( id , 'IsDefault' ) =1 THEN 'Default'
WHEN OBJECTPROPERTY ( id , 'IsForeignKey' ) =1 THEN 'Foreign Key'
WHEN OBJECTPROPERTY ( id , 'IsCheckCnst' ) =1 THEN 'Check Constraint'
WHEN OBJECTPROPERTY ( id , 'IsView' ) =1 THEN 'View'
WHEN OBJECTPROPERTY ( id , 'IsConstraint' ) =1 THEN 'Constraint'
WHEN OBJECTPROPERTY ( id , 'IsTrigger' ) =1 THEN 'Trigger'
WHEN OBJECTPROPERTY ( id , 'IsScalarFunction' ) =1 THEN 'Scalar Function'
WHEN OBJECTPROPERTY ( id , 'IsTableFunction' ) =1 THEN 'Table Valued Function'
WHEN OBJECTPROPERTY ( id , 'IsRule' ) =1 THEN 'Rule'
WHEN OBJECTPROPERTY ( id , 'IsExtendedProc' ) =1 THEN 'Extended Stored Procedure'
WHEN OBJECTPROPERTY ( id , 'IsUserTable' ) =1 THEN 'User Table'
END ObjectType, *
FROM sysobjects

And of course there are a bunch of INFORMATION_SCHEMA views that you can use to get some of the same information back

SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.VIEWS
SELECT * FROM INFORMATION_SCHEMA.COLUMNS


for example, want to find a procedure and drop it.
if exists (select * from dbo.sysobjects 
             where id = object_id('dbo.PROC_HELLOWORLD') 
                       and OBJECTPROPERTY(id, 'IsProcedure') = 1)
drop procedure dbo.PROC_HELLOWORLD;

another a bit difficult example, want to find a UDF and drop it.
if exists (select * from dbo.sysobjects
             where id = object_id('dbo.FUN_HELLOWORLD)
                      and type in ('FN', 'IF', 'TF', 'FS', 'FT'))
DROP FUNCTION dbo.FUN_HELLOWORLD



crazycy 2012-12-31 13:04 发表评论
]]>
SQLSERVER: ROWS TO COLUMNS 行{?Q二Q?http://www.aygfsteel.com/crazycy/archive/2012/10/04/389004.htmlcrazycycrazycyWed, 03 Oct 2012 17:33:00 GMThttp://www.aygfsteel.com/crazycy/archive/2012/10/04/389004.htmlhttp://www.aygfsteel.com/crazycy/comments/389004.htmlhttp://www.aygfsteel.com/crazycy/archive/2012/10/04/389004.html#Feedback1http://www.aygfsteel.com/crazycy/comments/commentRss/389004.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/389004.htmlCREATE TA...  阅读全文

crazycy 2012-10-04 01:33 发表评论
]]>
非常有意思的sql排错http://www.aygfsteel.com/crazycy/archive/2008/04/08/191534.htmlcrazycycrazycyTue, 08 Apr 2008 10:30:00 GMThttp://www.aygfsteel.com/crazycy/archive/2008/04/08/191534.htmlhttp://www.aygfsteel.com/crazycy/comments/191534.htmlhttp://www.aygfsteel.com/crazycy/archive/2008/04/08/191534.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/191534.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/191534.html1)  你看出区别在哪里了么Q?l果会一样么Q?br /> SELECT
(select first 
1 longname from ivctrallocpurch a join jcivloc l  on a.ivlocid=l.ivlocid and a.ctrid=A.ctrid) as mill
FROM CTR A
JOIN CTRSMRY CS ON (A.CTRID
=CS.CTRID)
WHERE A.CTRID
=3161
?br />
SELECT
(select first 
1 longname from ivctrallocpurch a join jcivloc l  on a.ivlocid=l.ivlocid and a.ctrid=3161) as mill
FROM CTR A
JOIN CTRSMRY CS ON (A.CTRID
=CS.CTRID)
WHERE A.CTRID
=3161
l果Z么不一样呢Q?br />

2Q?Integer overflow. The result of an integer operation caused the most significant bit of the result to carry.
select sum(rcpt.artothome * rate) as amt
from cashreceipt rcpt
join homerate rate on rcpt.currencyid=rate.currencyid
分析Q?br />
artothome @ arheader  is : numeric(18,4)
rate @ ..  is : numeric(
10,10)
改进1 (not work)
select sum(cast(rcpt.artothome * rate as numeric(18,4))) as amt
from cashreceipt rcpt
join homerate rate on rcpt.currencyid
=rate.currencyid
改进2 (works)
select sum(cast(cast(rcpt.artothome as numeric(18,4)) * cast(rate as numeric(18,4)) as numeric(18,4))) as amt
from cashreceipt rcpt
join homerate rate on rcpt.currencyid
=rate.currencyid
reason, forward from http://www.firebirdfaq.org/faq207/
Integer overflow. The result of an integer operation caused the most significant bit of the result to carry.

Short explanation:
If you use fixed precision datatypes (smallint, integer, bigint, decimal and numeric), it is possible that the result of calculation doesn
't fit the datatype. Try casting the values in complex expressions as double precision and see whether the error goes away. If it works and you don't care about being too precise, you can leave it at that. Otherwise you need to check every operation and calculate the result.

Details:
Here
's an example: if you multiply 9.12 with 8.11 (both numeric(18,2)) you would get 73.9632. If Firebird would store that into numeric(18,2) datatype, we would lose 0.0032. Doesn't look much, but when you have complex calculations, you can easily loose thousands (dollars or euros). Therefore, the result is stored in numeric(18,4).

Problems are rarely seen with such low precision as 
2. Let's use some bigger precision. For example, numeric(18,6) times numeric(18,6) yields numeric(18,12) result, meaning that maximal value it can store is 9223372.036854775807. If (for example) you wish to keep only 6 digits of precision, you could use something like:

cast(value1 as numeric(
18,3)) * cast(value2 as numeric(18,3))

which would yield numeric(
18,6) result, but it is quite possible that you would get more accurate result by casting to double:

cast(cast(value1 as 
double precision) * cast(value2 as double precision) as numeric(18,6))

Also, 
if you have mixed multiplications and divisions it helps to change the order of operations, so that the overflow doesn't happen.


String sql = "select mbrid from jcmbr where reference4=?";
假如没有记录
DynaBean aBean 
= CxcDataModule.getInstance().getRow(sql, new Object[]{reference4});
如果直接用aBean.get("
reference4") 出错Q?br /> 错误的原因是aBean  为null

Object obj 
= {spring jdbctemplate}.queryForObject(sql, new Object[]{reference4}, Integer.class);
if (obj instanceof Integer)
         System.out.println(
"(Integer)obj>>>>>>>>>>" + (Integer)obj);
else if (obj instanceof Map)
            System.out.println(
"(Integer)obj>>>>>>>>>>" + ((Map)obj).get("REFERENCE4"));
真是的流E是 if 分支
如果有数据,q是对的
如果没有数据Q直接出错,因ؓ有个假定有Integer值存?br />
int value = JcDataModuleUtils.getJdbcTemplate().queryForInt(sql, new Object[]{reference4});
出错原因是假定一定会有一个intD?/span>
15:09:00,438 ERROR [STDERR] Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size:
 expected 1, actual 0
15:09:00,438 ERROR [STDERR]     at org.springframework.dao.support.DataAccessUtils.requiredUniqueResult(DataAccessUtils.java:
66)
15:09:00,469 ERROR [STDERR]     at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:620)
15:09:00,469 ERROR [STDERR]     at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:629)
15:09:00,469 ERROR [STDERR]     at org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:656)






crazycy 2008-04-08 18:30 发表评论
]]>
mysqlq~码的解决之?不含分析) http://www.aygfsteel.com/crazycy/archive/2007/12/23/169827.htmlcrazycycrazycySun, 23 Dec 2007 10:07:00 GMThttp://www.aygfsteel.com/crazycy/archive/2007/12/23/169827.htmlhttp://www.aygfsteel.com/crazycy/comments/169827.htmlhttp://www.aygfsteel.com/crazycy/archive/2007/12/23/169827.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/169827.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/169827.html 以mysql的两个相同结构的表间q行数据q移ZQ做了三U情늚试Qƈ提出解决q的解x法如?

Migration between MySQLs

1)      Migration between character set : utf8

Amend my.ini (2 positions)

default-character-set=latin1

=>

default-character-set=utf8

2)      Migration between character set : origin is utf8 ==> the destination is latin1

Alter destination:

  • alter database [db_name] default character set utf8;
  • alter table [table_name] default character set utf8;
  •  alter table [table_name] change [field_name] [field_name] [filed type] varchar(45) character set utf8;
    • example

users(id, user_name)

alter table users  change user_name user_name varchar(45) character set utf8;

 

3)      Migration between character set : origin is latin1 ==> the destination is utf8

If the origin is latin1, cannot insert Chinese Character.

 




crazycy 2007-12-23 18:07 发表评论
]]>
firebird技巧和错误分析与ȝhttp://www.aygfsteel.com/crazycy/archive/2007/11/03/157940.htmlcrazycycrazycySat, 03 Nov 2007 09:06:00 GMThttp://www.aygfsteel.com/crazycy/archive/2007/11/03/157940.htmlhttp://www.aygfsteel.com/crazycy/comments/157940.htmlhttp://www.aygfsteel.com/crazycy/archive/2007/11/03/157940.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/157940.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/157940.html Cmd >> isql localhost/3050:path/cxcdata.fdb -user sysdba -pass masterkey
Error >>
Statement failed, SQLCODE = -902

Unable to complete network request to host "localhost".
-Failed to establish a connection.
-No connection could be made because the target machine actively refused it.

Use CONNECT or CREATE DATABASE to specify a database
Solution>>
check whether service or application of firebird start or not

2)
Scenario>>Using EMS Data Export for Interbase/Firebird
Error>>

Solution>>windows\system32\drivers\etc目录下的services文g中添?br />                 gds_db 3050/tcp

3) windows下firebird对db路径要求Q与firebird直接交互的fdb文g必须增加前缀Qlocalhost/3050:[driver]/{[path]/}[.fdb file]
    无论是isql q是 gbak
    比如 test.fdb 在d:\dbfile\firebird\test.fdb
    connect db: cmd>> isql localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]
    backup db: cmd>> gbak -B localhost/3050:d:/dbfile/firebird/test.fdb test.fbk -user [username] -pass [userpass]
    restore db: cmd>> gbak -C test.fbk localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]
    NOTE: only the fdb file should add the localhost constraint
   
   
4) db installed in d:/dbfile/firebird/test.fdb
    connect way 1>>  isql localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]
    connect way 2>> isql localhost/3050:db -user [username] -pass [userpass]
                               add this line : db = d:/dbfile/firebird/test.fdb  in aliases.conf, no need restart firebird service

5Qabout amention of db's path for different customer
we offten configure db path in apps using jdbc:firebird:localhost:[path]/[db file]   like jdbc:firebird:localhost: d:/dbfile/firebird/test.fdb
As you know, in most time we install db in different folder for different customers; so we must keep re-compile apps or modify war/jar/ear every time.

So basis on this issue,  we can change to configure db using firebird self file called aliases.conf
like this form (basis my local configuration):
test.fdb = d:/dbfile/firebird/test.fdb

so now using this form jdbc:firebird:localhost:test.fdb  in  apps
I tried both windows and linux, it works;



crazycy 2007-11-03 17:06 发表评论
]]>
得到PrepareStatement最l执行的sql语句的方?/title><link>http://www.aygfsteel.com/crazycy/archive/2006/07/22/59581.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 22 Jul 2006 13:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/crazycy/archive/2006/07/22/59581.html</guid><wfw:comment>http://www.aygfsteel.com/crazycy/comments/59581.html</wfw:comment><comments>http://www.aygfsteel.com/crazycy/archive/2006/07/22/59581.html#Feedback</comments><slash:comments>15</slash:comments><wfw:commentRss>http://www.aygfsteel.com/crazycy/comments/commentRss/59581.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/crazycy/services/trackbacks/59581.html</trackback:ping><description><![CDATA[在CSDN的JAVA基础?常常有h问及如何得到PreparedStatement最l执行的SQL语句;或者如何在控制台输出占位符的真实?....<br /><br />原因是PreparedStatement执行的sql语句有大量的占位W?....<br /><br />问题诸如JDBC?<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">如何得到 conn.prepareStatement 最l执行的sql语句?br />sql</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">update table1 set a=?,b=?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br />stmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> con.prepareStatement(sql);<br />stmt.setObjec t(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />stmt.setObjec t(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">b</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br />希望可以通过stmt或者conn 得到Q?br />update table1 set a</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,b</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">b</span><span style="color: rgb(0, 0, 0);">'</span></div><br />亦或Hibernate?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">如我执行Qfind(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">select * from t_table where id = ?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Integer(</span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">));<br />在控制台昄SQL时只昄Qselect </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> from t_table where id </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />如何才能做到控制台昄的占位符用其真实的值来替换Q?br />x制台输出时显C:select </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> from t_table where id </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br />无它Q无论JDBCq是Hiberante都不提供默认解决ҎQ但是参数是讄q去的,我们在设|的q程中可以有充分的理由来截取q获得自己想要的东西Q类gAOP理论?br /><br />׃n我在工程中的使用ҎQ?br />插入操作Q?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * 执行插入数据库的语句<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> q回生成的主?br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> executeInsert(String sql, Object[] params) {<br />        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        ResultSet rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得q接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 讄提交方式为程序控?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 讄SQL语句的参?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> params.length) {<br />                setParams(pstmt, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br />                getPreparedSQL(sql, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt.executeUpdate();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">7 E序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">8 q回生成的主?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pstmt.getGeneratedKeys();<br />            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> generatedKey </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (rs.next()) {<br />                generatedKey </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> rs.getInt(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />            }<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> generatedKey)<br />                </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">插入记录时出?/span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> generatedKey;<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br />        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt, rs);<br />        }<br />    }</span></div><br /><br />更新查找操作Q?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * 执行更新或者删除数据库的语?br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> q回执行成功与否<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> executeUpdateDel(String sql, Object[] params) {<br />        </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> isSuccess </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br />        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得q接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 讄提交方式为程序控?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 讄SQL语句的参?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> params.length) {<br />                setParams(pstmt, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br />                getPreparedSQL(sql, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt.executeUpdate();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">7 E序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">8 讄语句执行的标?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            isSuccess </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br />        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt);<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> isSuccess;<br />    }</span></div><br />执行查询<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 128, 0);">     * 执行查询数据库的语句;</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 128, 0);">     *<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> Object executeQuery(String sql, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        ResultSet rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得q接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 讄提交方式为程序控?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 讄SQL语句的参?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> params.length) {<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">                setParams(pstmt, params);<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">                getPreparedSQL(sql, params);<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pstmt.executeQuery();<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">9 E序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">10 获得记录</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            Object vo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object();<br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> rs </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"> rs.next()) {<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">                vo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> rs2vo(rs);<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">            return results;</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> vo;<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt, rs);<br /></span><span style="color: rgb(0, 128, 128);">51</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">52</span> <span style="color: rgb(0, 0, 0);">    }</span></div><br />看到<span style="color: rgb(0, 0, 0);">getPreparedSQL(sql, params)了么Q?q个地方是要实现我们预期效果的地方Q?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_215212" onclick="this.style.display='none'; Code_Closed_Text_215212.style.display='none'; Code_Open_Image_215212.style.display='inline'; Code_Open_Text_215212.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_215212" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_215212.style.display='none'; Code_Closed_Image_215212.style.display='inline'; Code_Closed_Text_215212.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_215212" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">得到PrepareStatement最l执行的sql语句的方?/span><span id="Code_Open_Text_215212" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 128, 0);">     * 获得PreparedStatement向数据库提交的SQL语句<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> String getPreparedSQL(String sql, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 如果没有参数Q说明是不是动态SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params)  paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> params.length;<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"> paramNum) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> sql;<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 如果有参敎ͼ则是动态SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        StringBuffer returnSQL </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> StringBuffer();<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">        String[] subSQL </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> sql.split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\\?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> paramNum; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (params[i] </span><span style="color: rgb(0, 0, 255);">instanceof</span><span style="color: rgb(0, 0, 0);"> Date) {<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">                returnSQL.append(subSQL[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> '</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).append(MyDateUtil.dateUtil2SQL((java.util.Date)params[i])).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">' </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">            } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">                returnSQL.append(subSQL[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> '</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).append(params[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">' </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (subSQL.length </span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"> params.length) {<br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">            returnSQL.append(subSQL[subSQL.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]);<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> returnSQL.toString();<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 128, 0);">     * 为PreparedStatement预编译的SQL语句讄参数<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> pstmt<br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setParams(PreparedStatement pstmt, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params) {<br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">, paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> params.length; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> paramNum; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">                    </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params[i] </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">                            params[i] </span><span style="color: rgb(0, 0, 255);">instanceof</span><span style="color: rgb(0, 0, 0);"> java.util.Date) {<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">                            pstmt.setDate(i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, MyDateUtil.dateUtil2SQL(<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">                                    (java.util.Date) params[i]));<br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);">                        } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 0, 0);">                            pstmt.setObject(i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, params[i]);<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">                        }<br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">                    } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">                    }<br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">                }<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 0, 0);">    }</span></span></div><br />然后L核实你的控制台或者日志文件吧......<br /></span><img src ="http://www.aygfsteel.com/crazycy/aggbug/59581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/crazycy/" target="_blank">crazycy</a> 2006-07-22 21:53 <a href="http://www.aygfsteel.com/crazycy/archive/2006/07/22/59581.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>An internal error occurred during: "Generating Artifacts" http://www.aygfsteel.com/crazycy/archive/2006/06/22/54502.htmlcrazycycrazycyThu, 22 Jun 2006 07:41:00 GMThttp://www.aygfsteel.com/crazycy/archive/2006/06/22/54502.htmlhttp://www.aygfsteel.com/crazycy/comments/54502.htmlhttp://www.aygfsteel.com/crazycy/archive/2006/06/22/54502.html#Feedback0http://www.aygfsteel.com/crazycy/comments/commentRss/54502.htmlhttp://www.aygfsteel.com/crazycy/services/trackbacks/54502.html
    google了一把,看到BlogQY道,urlQhttp://blog.csdn.net/langtaojin/archive/2006/03/28/641722.aspxQ介l如下:
今天在用myEclipse 的 Database Explorer 视图中Create Hibernate MappingӞ出现了“An internal error occurred during: "Generating Artifacts".”错误提C。费了好大劲Q终于解决了。据myEclipse官方|站上的介绍Q发生该错误主要有两U情况,一是你eclipse上安装了jboss公司的hibernate tools plugin for eclipse,q些插g与myEclipse发生冲突Q解x法是删除q些插g。二是你在没有卸载以前myEclipse版本的情况下安装了新?myEclipse版本Q解x法是把myEclipse卸蝲后重新安装,我遇到的情况属于每二种情况Q重装myEclipse后问题解决了?br />
    W一个问题不存在Q然后咣咣的卸蝲、安装了MyEclipse4.1.1。问题依然?br />
    手工建立试表,却没有这个问题。突然想C可能是数据表建立的格式有问题Q我用PD直接把物理实体模型导入到Mysql中。就它了。通过MyCCQ当然也可以通过命o?mysql -h localhost -u root -pQ把PD生成的SQL语句重新q行QOKQ问题解冟?br />
    l合上面的blogQ可以看出出现这个问题具有三U情况了?br />
    当然或许你用OracleQ也可能遇到q个问题Q如果以上三U情况都没有解决了An internal error occurred during: "Generating Artifacts" q个错误。你注意两点Q?PLSQL工具的问题,直接命o行?Orcle的class12驱动的版本,换新版本?br />



crazycy 2006-06-22 15:41 发表评论
]]>
վ֩ģ壺 ɽ| | ̨| | | | | Ͳ| | | ϰ| | | | | Ӳ| ɫ| ϰ| ˮ| | ػʵ| ̨| ͨ| Ұ| | żҽ| ع| ¡| ͨ| ͩ®| »| ¹| | ˼| ʡ| | | ָ| | º| Ҧ|