• myeclipse连接数据库遇到的几个问题


    1:无效的SQL URL:
    //将获取的参数插入数据库
            Connection conn=null;
            PreparedStatement stat=null;
            try {
                Class.forName("oracle.jdbc.OracleDriver");
                try {
                    conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl",
                            "system","oracle");
                    String sql="insert into t_emp values(t_emp_id_seq.nextval,?,?,?)";
                    stat=conn.prepareStatement(sql);
                    stat.setString(1,name);
                    stat.setDouble(2,salary);
                    stat.setInt(3,age);
                    stat.executeUpdate();
                    out.println("添加完成!");
                    out.close();
    错误的原因:thin的后面有:  ,很容易被忽略,以后做项目要注意

    2:第二个错误是java.sql.SQLException: Listener refused the connection with the following error:
    这个是sid错误的原因,本来是orcl,被我写成了xe,没有修改,使用了默认的了,以后做项目是应该留心。
  • 相关阅读:
    py-day2-4 python 集合
    LR_问题_控制器不能使用定义的负载生成器
    LR_问题_无法使用LR的Controller,提示缺少license
    LR_问题_在导入wsdl时出现parsing error
    class, extends和super es6语法
    格式化日期
    CLR
    【sqlserver】批量插入10万数据
    php正则表达式匹配函数
    css overflow
  • 原文地址:https://www.cnblogs.com/warrior4236/p/6055713.html
Copyright © 2020-2023  润新知