如果解决了您的问题请采纳!
如果未解决请继续追问
i think this should look like..applet
jdbc->lokal server someport
lokal sever someport
get data_for_sqlserver
embed data_for_sqlserver ->post_http_data_for_sqlserver
socket port 80->http://yourwebserver/servlet
send post_http_data_for_sqlserver (use POST)
is this ok for u ?
remote server with servlet
getPost post_http_data_for_sqlserver
unwrap post_http_data_for_sqlserver ->data_for_sqlserver
socket->mysql on right port
send data_for_sqlserver
receive data_from_sqlserver
embed data_from_sqlserver ->http_response_data_from_sqlserver
sendResponse http_response_data_from_sqlserver
lokal server someport
receive http_response_data_from_sqlserver
unwrap http_response_data_from_sqlserver ->data_from_sqlserver
send data_from_sqlserver
applet
jdbc.get data_from_sqlserver ->ResultSet
as you can see this is a lot of work and im not sure if you can open a
serverport in untrusted applets.
so if you can connect to port 80 without a runing webserver you can
write your own jdbc-redirect-proxy
applet
jdbc->your jdbcproxy on port 80
jdbcproxy
get data_to_sqlserver
socket->mysql on right port
send data_to_sqlserver
get response ->data_from_sqlserver
send data_from_sqlserver
applet
jdbc.get data_from_sqlserver ->ResultSet
如何用java 5分钟实现一个最简单的mysql代理服务器首先,准备开发工具套件,我们并不会引入过多工具包,仅仅需要:
java8
vert.x 3
如果你是用maven做为项目管理工具,请将vert.x 3引入:
1
2
3
4
5
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>3.3.2</version>
</dependency>
代码实现:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package
com.maxleap.mysqlproxy
import
io.vertx.core.AbstractVerticle
import
io.vertx.core.Vertx
import
io.vertx.core.logging.Logger
import
io.vertx.core.logging.LoggerFactory
import
io.vertx.core.net.NetClient
import
io.vertx.core.net.NetServer
import
io.vertx.core.net.NetSocket
/**
*
@author sneaky
*
@since 1.0.0
*/
public
class
MysqlProxyServer
{
private
static
final
Logger
logger
=
LoggerFactory.getLogger(MysqlProxyServer.class)
public
static
void
main(String[]
args)
{
Vertx.vertx().deployVerticle(new
MysqlProxyServerVerticle())
}
public
static
class
MysqlProxyServerVerticle
extends
AbstractVerticle
{
private
final
int
port
=
3306
private
final
String
mysqlHost
=
"10.10.0.6"
@Override
public
void
start()
throws
Exception
{
NetServer
netServer
=
vertx.createNetServer()//创建代理服务器
NetClient
netClient
=
vertx.createNetClient()//创建连接mysql客户端
netServer.connectHandler(socket
->
netClient.connect(port,
mysqlHost,
result
->
{
//响应来自客户端的连接请求,成功之后,在建立一个与目标mysql服务器的连接
if
(result.succeeded())
{
//与目标mysql服务器成功连接连接之后,创造一个MysqlProxyConnection对象,并执行代理方法
new
MysqlProxyConnection(socket,
result.result()).proxy()
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)