用socket连接数据库??为什么不用jdbc
解决方案 »
- 时间转换格式的小问题
- super.getHibernateTemplate().find(hql.toString());出错!
- SSH框架中HIbernate能查询删除更新,不能插入?
- com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
- J2EE API问题
- 请问如何把SPRING中的连接数据库信息封装到JAVABEAN中?用到了连接池c3p0(WEB版有同样一100分帖)
- 运行spring出现问题
- 错了吗?
- 关于jdbc的一点问题,希望得到帮助!
- 请教。。。
- 散分喽!用过hibernate的高人都可以得分。
- JSP如何通过JNDI连接数据库 ?
实际上不是直接连sqlserver或其他数据库
后台是一个提供socket接口的服务器,提供身份认证等功能
我所能看到的就是这个服务器
所以一定要用socket的
import java.net.*;class server
{
public static void main(String[] args)
{
try
{
ServerSocket ss=new ServerSocket(8000);
Socket stoc=ss.accept(); DataInputStream dis=new DataInputStream(stoc.getInputStream());
DataOutputStream dos=new DataOutputStream(stoc.getOutputStream()); while(true)
{
//String strc=dis.read();
int i=dis.read();
System.out.println("client: "+i); //strc=strc+" you!";
i++;
dos.write(i);
dos.flush();
System.out.println("server: "+i);
}
}
catch (IOException iex)
{
System.out.println(iex);
}
}
}class client
{
public static void main(String[] args)
{
try
{
Socket ctos=new Socket("localhost",8000); DataInputStream dis=new DataInputStream(ctos.getInputStream());
DataOutputStream dos=new DataOutputStream(ctos.getOutputStream()); int i=1; while(i<100)
{
//String strc="beauty";
//int i=1;
dos.write(i);
dos.flush();
System.out.println("client: "+i); i=dis.read();
i++;
System.out.println("server: "+i);
}
}
catch (IOException iex)
{
System.out.println(iex);
}
}
}
jsp还是只作为表示的好!
和servlet差不多吧?