首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

小白遇见低级异常,不会改jsp代码

2011-12-21 
小白遇见低级错误,不会改jsp代码我想用eclipse连接sqlserver但是不知道哪里出错了,请各位大侠帮我指出错误

小白遇见低级错误,不会改jsp代码
我想用eclipse连接sqlserver但是不知道哪里出错了
,请各位大侠帮我指出错误
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%>
  <%@page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% Connection con;
  try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
  }catch(ClassNotFoundException e){
out.print(e);
  }
  try{
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master");
con.close();
out.print("lianjichenggong!");
  }catch(SQLException e){
out.print(e);
 
  }
  %>

</body>
</html>

[解决办法]
在jsp中不好写java代码,建议如果确实想写入jsp中,请先将java代码在java程序中调试好后,再贴到jsp中。


http://w393185765.blog.163.com/blog/static/5672230620091127104258220/

http://simon700.blog.163.com/blog/static/30228542201002254154768/?fromdm&fromSearch&isFromSearchEngine=yes

[解决办法]
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master");
==》
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master",用户名,密码);

[解决办法]

探讨

con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master");
==》
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master",用户名,密码);

[解决办法]
探讨

con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master");
==》
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=master",用户名,密码);

热点排行