我使用hibernate连接sqlserver2000时总是提示Source not found for TDSRPCRequest(TDSRequest).processReply(BaseWarnings) line: not available这个错误,改了很多地方都没有解决。请帮忙解决下。在我使用mysql时没有错误,即修改server的hibernate配置文件后mysql即可使用server的配置文件hibernate.cfg.xml 为:<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="connection.username">sa</property>
<property name="connection.url">
jdbc:sqlserver://localhost:1433;DatabaseName=tt
</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="myeclipse.connection.profile">myConn</property>
<property name="connection.password">0</property>
<property name="connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<mapping resource="cn/com/tym/User.hbm.xml" /> </session-factory>
</hibernate-configuration>调用java为:public class TestA extends HttpServlet { protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
Session session = SessionFactory.currentSession();
Query query = session
.createQuery("from User as u where u.name=:username");
query.setString("username", name);
List list = query.list();//经多次验证,到这里list、或调用save时都会错误*************
System.out.println("ccc:" + list.size());
out.println("<pront>");
if (list.size() != 0) {
out.println("<content>" + "aaa!" + "</content>");
} else {
out.println("<content>" + "bbb!" + "</content>");
}
out.println("</pront>");
out.close(); }
}并且还有这样的警告提示:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.我只有可怜的10分,^_^,谢谢帮忙了
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="connection.username">sa</property>
<property name="connection.url">
jdbc:sqlserver://localhost:1433;DatabaseName=tt
</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="myeclipse.connection.profile">myConn</property>
<property name="connection.password">0</property>
<property name="connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<mapping resource="cn/com/tym/User.hbm.xml" /> </session-factory>
</hibernate-configuration>调用java为:public class TestA extends HttpServlet { protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
Session session = SessionFactory.currentSession();
Query query = session
.createQuery("from User as u where u.name=:username");
query.setString("username", name);
List list = query.list();//经多次验证,到这里list、或调用save时都会错误*************
System.out.println("ccc:" + list.size());
out.println("<pront>");
if (list.size() != 0) {
out.println("<content>" + "aaa!" + "</content>");
} else {
out.println("<content>" + "bbb!" + "</content>");
}
out.println("</pront>");
out.close(); }
}并且还有这样的警告提示:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.我只有可怜的10分,^_^,谢谢帮忙了
<%@ page import="java.lang.*, java.io.*, java.sql.*,
java.util.*" contentType="text/html;charset=gb2312" %>
<html>
<body>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tt";
//pubs 为你的数据库的
String user="sa";
String password="0"; //此处的密码可以更改, 在企业管理器中,找到 “安全性”--点击“登录”--右击 sa 选择“属性”--在里面对密码进行更改
Connection conn=
DriverManager.getConnection(url,user,password);
Statement
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from useraaa";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) { %>
您的第一个字段内容为:<%=rs.getString(1)%><br>
您的第二个字段内容为:<%=rs.getString(2)%><br>
<% } %>
<% out.print("数据库操作成功,恭喜你"); %>
<% rs.close();
stmt.close();
conn.close();
%>
</body>
</html> 如果上面能连得通,肯定就是Hibernate得配置问题了。