org.apache.jasper.JasperException: An exception occurred processing JSP page /tmp2.jsp at line 96:  out.println("Load the embedded driver"); 
7:  Connection conn = null; 
8:  //create and connect the database named helloDB 
9:  conn = DriverManager.getConnection("jdbc:derby://localhost:1527/helloDB;create=true", "", ""); 
10: 
11:  out.println("create and connect to helloDB"); 
12:  conn.setAutoCommit(false); 
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause javax.servlet.ServletException: java.sql.SQLNonTransientConnectionException: 用户标识长度(0)超出范围 1 到 255。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.tmp2_jsp._jspService(tmp2_jsp.java:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

解决方案 »

  1.   

    需要设定系统变量"derby.system.home",并指向derby数据库
    参考:http://objectmix.com/apache/648036-issues-when-connecting-database.html
      

  2.   

    derby.system.home系统变量设置了吗?指向数据库了吗?
      

  3.   


    package com.svse.util;import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;public class DBCon {
    public static String driver="oracle.jdbc.driver.OracleDriver";
    public static String url="jdbc:oracle:thin:@192.168.0.174:1521:ORCL";
    public static String user="scott";
    public static String pwd="tiger";

    public static Connection getConnection(){
    try {
    Class.forName(driver);
    Connection con=DriverManager.getConnection(url, user, pwd);
    System.out.println("con success");
    return con;
    } catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return null;
    }

    public static void close(Connection con,Statement stm,ResultSet rs){
    if(con!=null){
    try {
    con.close();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    if(stm!=null){
    try {
    stm.close();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    if(rs!=null){
    try {
    rs.close();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }

    public static void main(String[] args) {
    DBCon.getConnection();
    }
    }给你看下连接oracle的例子你代码太乱了  看不清楚