Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
cfc2be21
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,发现更多精彩内容 >>
提交
cfc2be21
编写于
8月 24, 2012
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixed
上级
cf3afe45
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
13 deletion
+80
-13
bee-engine/src/main/java/com/dianping/bee/engine/spi/meta/internal/TypeUtils.java
.../com/dianping/bee/engine/spi/meta/internal/TypeUtils.java
+61
-0
bee-engine/src/main/java/com/dianping/bee/server/SimpleDescHandler.java
.../main/java/com/dianping/bee/server/SimpleDescHandler.java
+11
-3
bee-engine/src/main/java/com/dianping/bee/server/SimpleShowHandler.java
.../main/java/com/dianping/bee/server/SimpleShowHandler.java
+6
-0
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
+2
-10
未找到文件。
bee-engine/src/main/java/com/dianping/bee/engine/spi/meta/internal/TypeUtils.java
浏览文件 @
cfc2be21
...
...
@@ -40,4 +40,65 @@ public class TypeUtils {
return
Fields
.
FIELD_TYPE_STRING
;
}
}
public
static
String
convertFieldTypeToString
(
int
field
)
{
switch
(
field
)
{
case
Fields
.
FIELD_TYPE_STRING
:
return
"CHAR"
;
case
Fields
.
FIELD_TYPE_INT24
:
return
"INTEGER"
;
case
Fields
.
FIELD_TYPE_DECIMAL
:
return
"DECIMAL"
;
case
Fields
.
FIELD_TYPE_TINY
:
return
"TINYINT"
;
case
Fields
.
FIELD_TYPE_SHORT
:
return
"SMALLINT"
;
case
Fields
.
FIELD_TYPE_LONG
:
return
"BIGINT"
;
case
Fields
.
FIELD_TYPE_FLOAT
:
return
"FLOAT"
;
case
Fields
.
FIELD_TYPE_DOUBLE
:
return
"DOUBLE"
;
case
Fields
.
FIELD_TYPE_NULL
:
return
"NULL"
;
case
Fields
.
FIELD_TYPE_TIMESTAMP
:
return
"TIMESTAMP"
;
case
Fields
.
FIELD_TYPE_LONGLONG
:
return
"BIGINT"
;
case
Fields
.
FIELD_TYPE_DATE
:
return
"DATE"
;
case
Fields
.
FIELD_TYPE_TIME
:
return
"TIME"
;
case
Fields
.
FIELD_TYPE_DATETIME
:
return
"DATETIME"
;
case
Fields
.
FIELD_TYPE_YEAR
:
return
"YEAR"
;
case
Fields
.
FIELD_TYPE_NEWDATE
:
return
"NEWDATE"
;
case
Fields
.
FIELD_TYPE_VARCHAR
:
return
"VARCHAR"
;
case
Fields
.
FIELD_TYPE_BIT
:
return
"BIT"
;
case
Fields
.
FIELD_TYPE_NEW_DECIMAL
:
return
"NEWDECIMAL"
;
case
Fields
.
FIELD_TYPE_ENUM
:
return
"ENUM"
;
case
Fields
.
FIELD_TYPE_SET
:
return
"SET"
;
case
Fields
.
FIELD_TYPE_TINY_BLOB
:
return
"TINYBLOB"
;
case
Fields
.
FIELD_TYPE_MEDIUM_BLOB
:
return
"MEDIUMBLOB"
;
case
Fields
.
FIELD_TYPE_LONG_BLOB
:
return
"LONGBLOB"
;
case
Fields
.
FIELD_TYPE_BLOB
:
return
"BLOBL"
;
case
Fields
.
FIELD_TYPE_VAR_STRING
:
return
"VARCHAR"
;
case
Fields
.
FIELD_TYPE_GEOMETRY
:
return
"GEOMETRY"
;
default
:
return
"UNKNOWN"
;
}
}
}
bee-engine/src/main/java/com/dianping/bee/server/SimpleDescHandler.java
浏览文件 @
cfc2be21
...
...
@@ -30,6 +30,7 @@ import com.alibaba.cobar.util.StringUtil;
import
com.dianping.bee.engine.spi.TableProvider
;
import
com.dianping.bee.engine.spi.TableProviderManager
;
import
com.dianping.bee.engine.spi.meta.ColumnMeta
;
import
com.dianping.bee.engine.spi.meta.internal.TypeUtils
;
import
com.site.lookup.annotation.Inject
;
/**
...
...
@@ -46,7 +47,13 @@ public class SimpleDescHandler {
*/
public
void
handle
(
String
stmt
,
ServerConnection
c
,
int
offset
)
{
String
tableName
=
stmt
.
substring
(
offset
).
trim
();
int
length
=
tableName
.
length
();
if
(
length
>
0
)
{
if
(
tableName
.
charAt
(
0
)
==
'`'
&&
tableName
.
charAt
(
length
-
1
)
==
'`'
)
{
tableName
=
tableName
.
substring
(
1
,
length
-
1
);
}
}
// 检查当前使用的DB
String
db
=
c
.
getSchema
();
if
(
db
==
null
)
{
...
...
@@ -109,7 +116,9 @@ public class SimpleDescHandler {
for
(
ColumnMeta
column
:
columns
)
{
RowDataPacket
row
=
new
RowDataPacket
(
FIELD_COUNT
);
row
.
add
(
StringUtil
.
encode
(
column
.
getName
(),
c
.
getCharset
()));
row
.
add
(
StringUtil
.
encode
(
column
.
getType
().
getSimpleName
(),
c
.
getCharset
()));
row
.
add
(
StringUtil
.
encode
(
TypeUtils
.
convertFieldTypeToString
(
TypeUtils
.
convertJavaTypeToFieldType
(
column
.
getType
())),
c
.
getCharset
()));
row
.
add
(
null
);
row
.
add
(
null
);
row
.
add
(
null
);
...
...
@@ -137,5 +146,4 @@ public class SimpleDescHandler {
// post write
c
.
write
(
buffer
);
}
}
bee-engine/src/main/java/com/dianping/bee/server/SimpleShowHandler.java
浏览文件 @
cfc2be21
...
...
@@ -78,6 +78,12 @@ public class SimpleShowHandler {
*/
private
void
showTableStatus
(
ServerConnection
c
,
String
stmt
)
{
String
dbName
=
stmt
.
substring
(
"show table status from "
.
length
()).
trim
();
int
length
=
dbName
.
length
();
if
(
length
>
0
)
{
if
(
dbName
.
charAt
(
0
)
==
'`'
&&
dbName
.
charAt
(
length
-
1
)
==
'`'
)
{
dbName
=
dbName
.
substring
(
1
,
length
-
1
);
}
}
DatabaseProvider
provider
=
null
;
try
{
...
...
bee-engine/src/test/java/com/dianping/bee/jdbc/JDBCTest.java
浏览文件 @
cfc2be21
...
...
@@ -17,12 +17,10 @@ package com.dianping.bee.jdbc;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
import
com.dianping.bee.server.SimpleServer
;
import
com.site.lookup.ComponentTestCase
;
/**
...
...
@@ -31,14 +29,6 @@ import com.site.lookup.ComponentTestCase;
@RunWith
(
JUnit4
.
class
)
public
class
JDBCTest
extends
ComponentTestCase
{
private
SimpleServer
server
;
@Before
public
void
runServer
()
throws
Exception
{
server
=
lookup
(
SimpleServer
.
class
);
server
.
startup
();
}
@Test
public
void
testConnection
()
{
Connection
conn
=
null
;
...
...
@@ -49,6 +39,8 @@ public class JDBCTest extends ComponentTestCase {
String
password
=
"test"
;
try
{
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"
);
conn
.
close
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录