Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
2865c749
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2865c749
编写于
8月 28, 2012
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixbugs
上级
660b089f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
19 deletion
+50
-19
bee-engine/src/main/java/com/dianping/bee/engine/spi/handler/internal/SelectHandler.java
...anping/bee/engine/spi/handler/internal/SelectHandler.java
+3
-1
bee-engine/src/main/java/com/dianping/bee/engine/spi/handler/internal/ShowHandler.java
...dianping/bee/engine/spi/handler/internal/ShowHandler.java
+31
-11
bee-engine/src/main/java/com/dianping/bee/server/SimpleServerQueryHandler.java
...ava/com/dianping/bee/server/SimpleServerQueryHandler.java
+1
-1
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
+15
-6
未找到文件。
bee-engine/src/main/java/com/dianping/bee/engine/spi/handler/internal/SelectHandler.java
浏览文件 @
2865c749
...
...
@@ -35,6 +35,7 @@ import com.dianping.bee.engine.spi.meta.ColumnMeta;
import
com.dianping.bee.engine.spi.meta.Row
;
import
com.dianping.bee.engine.spi.meta.RowSet
;
import
com.dianping.bee.engine.spi.meta.internal.TypeUtils
;
import
com.site.helper.Joiners
;
import
com.site.lookup.annotation.Inject
;
/**
...
...
@@ -61,7 +62,8 @@ public class SelectHandler extends AbstractCommandHandler {
selectSession
(
c
,
first
.
substring
(
"@@SESSION."
.
length
()));
}
else
{
try
{
selectStatement
(
c
,
first
);
String
stmt
=
"select "
+
Joiners
.
by
(
' '
).
join
(
parts
);
selectStatement
(
c
,
stmt
);
}
catch
(
SQLSyntaxErrorException
e
)
{
error
(
c
,
ErrorCode
.
ER_SYNTAX_ERROR
,
e
.
getMessage
());
}
...
...
bee-engine/src/main/java/com/dianping/bee/engine/spi/handler/internal/ShowHandler.java
浏览文件 @
2865c749
...
...
@@ -35,10 +35,9 @@ public class ShowHandler extends AbstractCommandHandler {
showStatus
(
c
);
}
else
if
(
"variables"
.
equalsIgnoreCase
(
first
))
{
showVariables
(
c
);
}
else
if
(
"collation"
.
equalsIgnoreCase
(
first
)){
}
else
if
(
"collation"
.
equalsIgnoreCase
(
first
))
{
showCollation
(
c
);
}
else
{
}
else
{
error
(
c
,
ErrorCode
.
ER_UNKNOWN_COM_ERROR
,
"Unsupported show command"
);
}
}
...
...
@@ -46,7 +45,7 @@ public class ShowHandler extends AbstractCommandHandler {
/**
* @param c
*/
private
void
showCollation
(
ServerConnection
c
)
{
private
void
showCollation
(
ServerConnection
c
)
{
CommandContext
ctx
=
new
CommandContext
(
c
);
String
[]
names
=
{
"Collation"
,
"Charset"
,
"Id"
,
"Default"
,
"Compiled"
,
"Sortlen"
};
...
...
@@ -57,12 +56,12 @@ public class ShowHandler extends AbstractCommandHandler {
}
ctx
.
writeEOF
();
// TODO real data here
ctx
.
writeEOF
();
ctx
.
complete
();
}
}
private
void
showStatus
(
ServerConnection
c
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
...
...
@@ -152,9 +151,9 @@ public class ShowHandler extends AbstractCommandHandler {
TableProvider
[]
tables
=
provider
.
getTables
();
CommandContext
ctx
=
new
CommandContext
(
c
);
String
[]
names
=
{
"Name"
,
"Engine"
,
"Version"
,
"Row_format"
,
"Rows"
,
"Avg_row_length"
,
"Data_length"
,
"Max_data_length"
,
"
Index_length"
,
"Data_free"
,
"Auto_increment"
,
"Create_time"
,
"Update_time"
,
"Check_time"
,
"Collation"
,
"Checksum
"
,
"Create_options"
,
"Comment"
};
String
[]
names
=
{
"Name"
,
"Engine"
,
"Version"
,
"Row_format"
,
"Rows"
,
"Avg_row_length"
,
"Data_length"
,
"
Max_data_length"
,
"Index_length"
,
"Data_free"
,
"Auto_increment"
,
"Create_time"
,
"Update_time
"
,
"C
heck_time"
,
"Collation"
,
"Checksum"
,
"C
reate_options"
,
"Comment"
};
ctx
.
writeHeader
(
names
.
length
);
...
...
@@ -181,9 +180,30 @@ public class ShowHandler extends AbstractCommandHandler {
private
void
showVariables
(
ServerConnection
c
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"BeeStatus"
,
"Good"
);
// map.put("language","");
map
.
put
(
"net_write_timeout"
,
"60"
);
map
.
put
(
"interactive_timeout"
,
"28800"
);
map
.
put
(
"wait_timeout"
,
"28800"
);
map
.
put
(
"character_set_client"
,
"gbk"
);
map
.
put
(
"character_set_connection"
,
"gbk"
);
// map.put("character_set","");
map
.
put
(
"character_set_server"
,
"latin1"
);
map
.
put
(
"tx_isolation"
,
"REPEATABLE-READ"
);
map
.
put
(
"transaction_isolation"
,
""
);
map
.
put
(
"character_set_results"
,
"gbk"
);
// map.put("timezone","");
map
.
put
(
"time_zone"
,
"SYSTEM"
);
map
.
put
(
"system_time_zone"
,
""
);
map
.
put
(
"lower_case_table_names"
,
"1"
);
map
.
put
(
"max_allowed_packet"
,
"1048576"
);
map
.
put
(
"net_buffer_length"
,
"8192"
);
map
.
put
(
"sql_mode"
,
""
);
map
.
put
(
"query_cache_type"
,
"ON"
);
map
.
put
(
"query_cache_size"
,
"0"
);
map
.
put
(
"init_connect"
,
""
);
// TODO real data here
CommandContext
ctx
=
new
CommandContext
(
c
);
String
[]
names
=
{
"Variable_name"
,
"Value"
};
...
...
bee-engine/src/main/java/com/dianping/bee/server/SimpleServerQueryHandler.java
浏览文件 @
2865c749
...
...
@@ -43,7 +43,7 @@ public class SimpleServerQueryHandler implements FrontendQueryHandler {
case
SimpleServerParse
.
SET
:
SetHandler
.
handle
(
sql
,
c
,
rs
>>>
8
);
break
;
case
SimpleServerParse
.
DESC
:
case
SimpleServerParse
.
DESC
:
// New added
m_descHandler
.
handle
(
sql
,
c
,
rs
>>>
8
);
break
;
case
SimpleServerParse
.
SHOW
:
...
...
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
浏览文件 @
2865c749
...
...
@@ -17,6 +17,7 @@ package com.dianping.bee.jdbc;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.Statement
;
import
org.junit.Test
;
...
...
@@ -62,18 +63,26 @@ public class JDBCTest extends ComponentTestCase {
String
password
=
"test"
;
Class
.
forName
(
driver
).
newInstance
();
System
.
out
.
println
(
"Driver loaded"
);
DriverManager
.
setLoginTimeout
(
600
);
conn
=
DriverManager
.
getConnection
(
url
+
dbName
,
userName
,
password
);
System
.
out
.
println
(
"
Connected to the database
"
);
System
.
out
.
println
(
"
Query began
"
);
Statement
stmt
=
conn
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"select type, sum(failures) from transaction where domain=? and starttime=?"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
int
columns
=
meta
.
getColumnCount
();
for
(
int
column
=
1
;
column
<=
columns
;
column
++)
{
String
columnName
=
meta
.
getColumnName
(
column
);
System
.
out
.
print
(
columnName
+
"\t"
);
}
System
.
out
.
println
();
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getString
(
1
));
for
(
int
column
=
1
;
column
<=
columns
;
column
++)
{
System
.
out
.
print
(
rs
.
getString
(
column
)
+
"\t"
);
}
System
.
out
.
println
();
}
conn
.
close
();
System
.
out
.
println
(
"
Disconnected from database
"
);
System
.
out
.
println
(
"
Query Finished
"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录