java.sql.SQLException错误

运行StuDialog.class出现下面错误提示,初学Java请求帮助找出下面是什么原因?
java.sql.SQLException: No value specified for parameter 2
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2560)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2536)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2383)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2327)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2312)
at com.studentmanager.StuAddDialog.actionPerformed(StuAddDialog.java:109)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
at java.awt.Dialog$1.run(Dialog.java:1051)
at java.awt.Dialog$3.run(Dialog.java:1103)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:1101)
at java.awt.Component.show(Component.java:1516)
at java.awt.Component.setVisible(Component.java:1468)
at java.awt.Window.setVisible(Window.java:841)
at java.awt.Dialog.setVisible(Dialog.java:991)
at com.studentmanager.StuAddDialog.(StuAddDialog.java:73)
at com.studentmanager.StuDialog.actionPerformed(StuDialog.java:109)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

1、StuDialog.class如下:
package com.studentmanager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Vector;
public class StuDialog extends JFrame implements ActionListener{

//定义一些控件
JPanel jp1,jp2;
JLabel jl1;
JButton jb1,jb2,jb3,jb4;
JTable jt;
JScrollPane jsp;
JTextField jtf;


public static void main(String[] args) {
    // TODO Auto-generated method stub
    StuDialog stuDialog=new StuDialog();

}
public StuDialog()
{
    jp1=new JPanel();
    jtf=new JTextField(10);
    jb1=new JButton("查询");
    jb1.addActionListener(this);
    jl1=new JLabel("请输入名字");

    //把各个控件加入到jp1
    jp1.add(jl1);
    jp1.add(jtf);
    jp1.add(jb1);

    jp2=new JPanel();

    jb2=new JButton("添加");
    jb2.addActionListener(this);
    jb3=new JButton("修改");
    jb4=new JButton("删除");

    //把各个按钮就加入到jp2
    jp2.add(jb2);
    jp2.add(jb3);
    jp2.add(jb4);


    /*//rowData可以存放多行
    Vector hang=new Vector();
    hang.add("sp001");
    hang.add("孙悟空");
    hang.add("男");
    hang.add("25");
    hang.add("火锅山");
    hang.add("少林派");

    //加入到rowData
    rowData.add(hang);*/

    //创建一个数据模型对象
    StuModel sm=new StuModel();

    //初始化JTable
    jt=new JTable(sm);

    //初始化Jsp JScrollPane
    jsp=new JScrollPane(jt);

    //把jsp放入JFrame
    this.add(jsp);
    this.add(jp1,"North");
    this.add(jp2,"South");
    this.setSize(400,300);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);



}
@Override
public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    //判断是哪个按钮被点击
    if(e.getSource()==jb1)
    {
        System.out.println("用户想查询");
        //因为把表的现实的数据封装到StuModel中,那么我们就可以
        //简单完成查询
        //查询数据库,更新JTable

        String name=this.jtf.getText().trim();
        //写一个SQL语句
        String sql="select * from stu where stuName='"+name+"'";
        //构建新的数据模型,并更新
        StuModel sm=new StuModel(sql);
        //更新JTable
        jt.setModel(sm);

        //当用户点击添加

    }
    else if(e.getSource()==jb2)
    {
        StuAddDialog sa=new StuAddDialog(this,"添加学生",true);
        //重新再获得新的数据模型
    }
}

}

2、StuAddDialog.class如下:
package com.studentmanager;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.JDialog;
import java.sql.*;
public class StuAddDialog extends JDialog implements ActionListener {

    //定义我需要的swing控件
JPanel jp1,jp2,jp3;
JTextField jtf1,jtf2,jtf3,jtf4,jtf5,jtf6;
JButton jb1,jb2;
JLabel jl1,jl2,jl3,jl4,jl5,jl6;
//owner 它的父窗口
//title窗口名
//model指定是模式窗口,还是非模式窗口
public StuAddDialog(Frame owner,String title,boolean modal)
{
    super(owner,title,modal);//调用父类构造方法,达到模式对话框效果
    jl1=new JLabel("学号");
    jl2=new JLabel("姓名");
    jl3=new JLabel("性别");
    jl4=new JLabel("年龄");
    jl5=new JLabel("籍贯");
    jl6=new JLabel("系别");

    jtf1=new JTextField(); 
    jtf2=new JTextField();
    jtf3=new JTextField();
    jtf4=new JTextField();
    jtf5=new JTextField();
    jtf6=new JTextField();

    jb1=new JButton("添加");
    jb1.addActionListener(this);
    jb2=new JButton("取消");

    jp1=new JPanel();
    jp2=new JPanel();
    jp3=new JPanel();

    //设置布局
    jp1.setLayout(new GridLayout(6,1));
    jp2.setLayout(new GridLayout(6,1));

    jp1.add(jl1);
    jp1.add(jl2);
    jp1.add(jl3);
    jp1.add(jl4);
    jp1.add(jl5);
    jp1.add(jl6);

    jp2.add(jtf1);
    jp2.add(jtf2);
    jp2.add(jtf3);
    jp2.add(jtf4);
    jp2.add(jtf5);
    jp2.add(jtf6);

    jp3.add(jb1);
    jp3.add(jb2);

    this.add(jp1,BorderLayout.WEST);
    this.add(jp2,BorderLayout.CENTER);
    this.add(jp3,BorderLayout.SOUTH);

    jb1.addActionListener(this);

    //展现
    this.setSize(300,250);
    //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);


}

public void actionPerformed(ActionEvent e)
{
    if(e.getSource()==jb1)
    {
        //对用户点击添加按钮后的响应动作
        //连接数据库
        Connection ct=null;
        Statement stmt=null;
        ResultSet rs=null;
        PreparedStatement psmt=null;
        //连接数据库,判断用户是否合法
        try{
            //1加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            //2创建连接对象,注册驱动程序并打开连接对象
            ct=DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=GBK","root","123456");
            psmt=ct.prepareStatement("select * from stu");
            //3获取语句对象
            //stmt=ct.createStatement();
            //与编译语句对象
            psmt=ct.prepareStatement("insert into stu values(?,?,?,?,?,?)");

            //给参数赋值
            psmt.setString(1,jtf1.getText());
            psmt.setString(1,jtf2.getText());
            psmt.setString(1,jtf3.getText());
            psmt.setString(1,jtf4.getText());
            psmt.setString(1,jtf5.getText());
            psmt.setString(1,jtf6.getText());

            //4执行操作
            psmt.executeUpdate();

            this.dispose();//关闭对话框



        }catch(ClassNotFoundException e1)
        {
            e1.printStackTrace();
        }catch(SQLException e2)
        {
            e2.printStackTrace();
        }
        finally
        {
            //释放语句对象,连接对象
            try
            {
                if(rs!=null) rs.close();
                if(stmt!=null) stmt.close();
                if(ct!=null) ct.close();

            }catch(Exception e2)
            {
                e2.printStackTrace();
            }
        }

    }
}

@Override
public Container getContentPane() {
    // TODO Auto-generated method stub
    return super.getContentPane();
}

@Override
public void setContentPane(Container contentPane) {
    // TODO Auto-generated method stub
    super.setContentPane(contentPane);
}

}

3个回答

[code="java"]
//与编译语句对象
psmt=ct.prepareStatement("insert into stu values(?,?,?,?,?,?)");

//给参数赋值
psmt.setString(1,jtf1.getText());
psmt.setString(1,jtf2.getText());
psmt.setString(1,jtf3.getText());
psmt.setString(1,jtf4.getText());
psmt.setString(1,jtf5.getText());
psmt.setString(1,jtf6.getText());
[/code]
很明显的,你在考验我的视力,下标全是1,那后面的全都为空了,所以他会说第二个参数没有值呀! :oops:

[code="java"]
//给参数赋值
psmt.setString(1,jtf1.getText());
psmt.setString(1,jtf2.getText());
psmt.setString(1,jtf3.getText());
psmt.setString(1,jtf4.getText());
psmt.setString(1,jtf5.getText());
psmt.setString(1,jtf6.getText());
[/code]
what happend?为什么下标全是1?

:P 呵呵,当局者迷,旁观者清呀,写代码久了就这样呀,我这段时间也老犯糊涂,所以就想上这里找个比我更晕胡的,呵呵,找到了,就你了 :lol:

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Could not obtain connection metadata java.sql.SQLException错误,大家帮忙看看,着急
使用SpringMVC、Hibernate,现在tomcat启动报错。报错信息如下,请大家帮忙看看。谢谢! [color=green][color=blue]org.hibernate.connection.ConnectionProviderFactory.initializeConnectionProviderFromConfig(ConnectionProviderFactory.java:173) [INFO] - Initializing connection provider: org.springframework.orm.hibernate3.TransactionAwareDataSourceConnectionProvider 2013-07-08 16:20:18.933 [main] org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:140) [WARN] - Could not obtain connection metadata java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113) at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210) at $Proxy19.getMetaData(Unknown Source) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:116) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:701) at org.apache.catalina.startup.Catalina.start(Catalina.java:585) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)[/color][/color]
eclipse链接oracle 报java.sql.SQLException: 列名无效 错误!
代码如下 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Test{ private static String url="jdbc:oracle:thin:@192.168.3.205:1521:hsygt"; private static String user="VIDEO";//用户名 private static String password="VIDEO";//密码 public static void main(String[] args) { Connection conn=null;//创建一个数据库连接 PreparedStatement pre=null;//创建一个预编译语句对象,一般都是用这个而不用Statement ResultSet result=null;//创建一个结果集对象 try{ //1)new一个数据库驱动实例 加载Oracle驱动程序 Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("开始尝试连接数据库"); //new oracle.jdbc.driver.OracleDriver();//new的第二个方法 //2)连接oracle数据库 conn=DriverManager.getConnection(url,user,password); System.out.println("连接陈功"); //3)执行SQL语句 String sql="select * from Tv_Business"; pre=conn.prepareStatement(sql); result=pre.executeQuery(); while(result.next()){ System.out.println("ID: "+result.getString("id")+", NAME: "+result.getString("name")); } }catch(ClassNotFoundException e){ e.printStackTrace(); }catch(SQLException e) { e.printStackTrace(); }finally { try { // 逐一将上面的几个对象关闭,因为不关闭的话会影响性能、并且占用资源 // 注意关闭的顺序,最后使用的最先关闭 if (result != null){ result.close(); result=null; } if (pre != null){ pre.close(); pre=null; } if (conn != null){ conn.close(); conn=null; } System.out.println("数据库连接已关闭!"); } catch (SQLException e) { e.printStackTrace(); } } } }![图片说明](https://img-ask.csdn.net/upload/201708/01/1501576888_676984.png) ![图片说明](https://img-ask.csdn.net/upload/201708/01/1501576904_669004.png)
java.sql.SQLException: No value specified for parameter 5
数据库连接成功! java.sql.SQLException: No value specified for parameter 5 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920) at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2594) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2569) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350) at com.ShoppingC.dao.ProductDao.insertPro(ProductDao.java:113) at org.apache.jsp.proADDCtrl_jsp._jspService(proADDCtrl_jsp.java:148) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1156) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:844) 总是报这个错误 public int insertPro(Product pro) { int flag=0; String sql="INSERT INTO product(proName,proDetail,price) VALUES(?,?,?)"; try { pstmt=conn.prepareStatement(sql); pstmt.setString(1, pro.getProName()); pstmt.setString(2, pro.getProDetail()); pstmt.setDouble(3, pro.getPrice()1); flag=pstmt.executeUpdate(); System.out.println("商品添加成功!"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return flag; }
Cause: java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列:
在服务器上执行程序报如下错误: Error querying database. Cause: java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: PLS-00201: identifier 'IREVIEW.PROC_ECREDIT_INTEGRATION' must be declared 在开发环境执行IREVIEW.PROC_ECREDIT_INTEGRATION存储过程不会发生报错,那位哥哥知道什么原因?交兄弟一下,十分感谢
java.sql.SQLException: 列名无效
表单添加的时候数据库能正常添加这一行,但是控制台上还是会报 java.sql.SQLException: 列名无效 这个错误?请问怎么回事啊~~~急 //插入方法 public void insert(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{ Connection conn=null; Statement stat=null; String id=request.getParameter("userid"); String name=request.getParameter("username"); String userage=request.getParameter("age"); String gender=request.getParameter("gender"); conn=connect(); stat=conn.createStatement(); stat.execute("insert into userinfos(userid,username,sex,age) values("+id+",'"+name+"','"+gender+"',"+userage+")"); close(stat,conn); }
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器]
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 在指定的 DSN 中,驱动程序和应用程序之间不匹配 import java.sql.*; public class example { public static void main(String[] args) { // TODO 自动生成的方法存根 Connection con; Statement sql; ResultSet rs; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e){ System.out.print(e); } try{ con = DriverManager.getConnection("jdbc:odbc:star","",""); sql = con.createStatement(); rs = sql.executeQuery("SELECT * FROM employee WHERE salary > 1900"); while(rs.next()){ String number = rs.getString(1); String name = rs.getString(2); Date date = rs.getDate("birthday"); double salary = rs.getDouble("salary"); System.out.printf("% - 4s",number); System.out.printf("% - 6s",name); System.out.printf("% - 15s",date.toString()); System.out.printf("% 6s\n",salary); } con.close(); } catch(SQLException e){ System.out.println(e); } } } 以上代码在eclipse上运行出现错误,系统是64位的,用的是sysWoW64中的odbcad32创建的数据源,求解啊,小白一个= =
java.sql.SQLException: Column 'gp_id' not found.错误
[color=red]在hibernate中调用存储过程,其中我的存储过程编写如下:[/color] [code="java"] DELIMITER $$ DROP PROCEDURE IF EXISTS `qdrk`.`undobusiness`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `undobusiness`() BEGIN DECLARE business_date timestamp default current_timestamp; DECLARE mon int; SELECT business_date; SELECT max(plandate) into business_date from jz_business_plan; SELECT business_date; set mon = DATE_FORMAT(business_date,'%m'); WHILE (mon < DATE_FORMAT(Now(),'%m')) do select g_id ,gb_id,account_id,bs_id from jz_gbmes where ((stday < date_format(Now(),'%d') and enday > date_format(Now(),'%d') and remindtype= '2'); insert into jz_business_plan(g_id,gb_id,account_id,bs_id) values(g_id,gb_id,account_id,bs_id); set mon = mon+1; end WHILE; SELECT * from jz_business_plan WHERE DATE_FORMAT(jz_business_plan.plandate,'%m') = DATE_FORMAT(now(),'%m'); END$$ DELIMITER ; [/code] [color=red]hibernate的配置文件如下:[/color][code="java"] <hibernate-mapping> <class name="cn.qdrk.strive.model.JzBusinessPlan" table="jz_business_plan" catalog="qdrk"> <id name="gpId" type="java.lang.Integer"> <column name="gp_id" /> <generator class="native"></generator> </id> <many-to-one name="accountTable" class="cn.qdrk.strive.model.AccountTable" fetch="select"> <column name="account_id" /> </many-to-one> <many-to-one name="jzBusiness" class="cn.qdrk.strive.model.JzBusiness" fetch="select"> <column name="bs_id" /> </many-to-one> <many-to-one name="jzGuestbook" class="cn.qdrk.strive.model.JzGuestbook" fetch="select"> <column name="gb_id" /> </many-to-one> <many-to-one name="jzGbmes" class="cn.qdrk.strive.model.JzGbmes" fetch="select"> <column name="g_id" /> </many-to-one> <property name="plandate" type="java.util.Date"> <column name="plandate" length="19" not-null="true" /> </property> <property name="remark" type="java.lang.String"> <column name="remark" /> </property> </class> <sql-query name="undobusiness" callable="true"> <return alias="JzBusinessPlan" class="cn.qdrk.strive.model.JzBusinessPlan"> <return-property name="gpId" column="gp_id"/> <return-property name="jzGbmes" column="g_id" /> <return-property name="accountTable" column="account_id"/> <return-property name="jzBusiness" column="bs_id" /> <return-property name="plandate" column="plandate" /> <return-property name="remark" column="remark" /> <return-property name="jzGuestbook" column="gb_id" /> </return> {call undobusiness()} </sql-query> </hibernate-mapping> [/code] [color=red]dao接口:[/color][code="java"] public List undoBusiness() { List list = this.getSession().getNamedQuery("undobusiness").list(); [/code] [color=red]我的表jz_business_plan定义如下:[/color] [code="java"] CREATE TABLE jz_business_plan( gp_id int(10) unsigned NOT NULL auto_increment, g_id int(11) unsigned default NULL, account_id int(11) unsigned default NULL, bs_id int unsigned default null, plandate timestamp NOT NULL default CURRENT_TIMESTAMP, remark varchar(255) default NULL, gb_id int unsigned default null, index (gb_id), FOREIGN KEY (gb_id) REFERENCES jz_guestbook (gb_id), index (account_id), FOREIGN KEY (account_id) REFERENCES account_table(account_id) , index (g_id), FOREIGN KEY (g_id) REFERENCES jz_gbmes(g_id), index (bs_id), FOREIGN KEY (bs_id) REFERENCES jz_business(bs_id) , PRIMARY KEY (gp_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; [/code] 我调用的时候会出现java.sql.SQLException: Column 'gp_id' not found.错误,用这种方式调用其他的存储过程时没有错误,郁闷!难道我的存储过程有问题么? 错误信息如下: [code="java"] 2008-11-13 08:33:13,382 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: S0022 2008-11-13 08:33:13,382 ERROR [org.hibernate.util.JDBCExceptionReporter] - Column 'gp_id' not found. org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2148) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164) at cn.qdrk.strive.dao.hibernate.CRMDaoHibernate.undoBusiness(CRMDaoHibernate.java:43) [color=red]at cn.qdrk.strive.dao.hibernate.CRMDaoHibernate$$FastClassByCGLIB$$afe1117e.invoke(<generated>)[/color] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) [/code] [code="java"] [color=red]Caused by: java.sql.SQLException: Column 'gp_id' not found.[/color] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1093) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734) at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:237) [/code]
java.sql.SQLException: An attempt by a client to checkout a Connection has timed
这是项目在启动的时候出现的错误,哪位高人可以给讲解一下啊?遇到过好多次了!![code="java"]java.sql.SQLException: An attempt by a client to checkout a Connection has timed out. at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at com.jdlx.common.ConnectionFactory.getConnection(ConnectionFactory.java:42) at cn.com.jdlh.supervise.ServiceDao.init(ServiceDao.java:102) at cn.com.jdlh.supervise.servlet.Data2XMLServlet.init(Data2XMLServlet.java:60) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@16d4d81 -- timeout at awaitAvailable() at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 31 more [/code]
使用Mybatis的代码生成器报错java.sql.SQLException: Column 'IS_GENERATEDCOLUMN' not found.
我在使用mybatis的代码生成器生成代码的时候报错如下 : java.sql.SQLException: Column 'IS_GENERATEDCOLUMN' not found. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1093) at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5488) at org.mybatis.generator.internal.db.DatabaseIntrospector.getColumns(DatabaseIntrospector.java:619) at org.mybatis.generator.internal.db.DatabaseIntrospector.introspectTables(DatabaseIntrospector.java:221) at org.mybatis.generator.config.Context.introspectTables(Context.java:653) at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:257) at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:139) at com.Junit.Test.test(Test.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.util.ArrayList.forEach(ArrayList.java:1249) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.util.ArrayList.forEach(ArrayList.java:1249) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 这是我生成代码的测试类: package com.Junit; import org.mybatis.generator.api.MyBatisGenerator; import org.mybatis.generator.config.Configuration; import org.mybatis.generator.config.xml.ConfigurationParser; import org.mybatis.generator.internal.DefaultShellCallback; import org.springframework.cglib.core.DefaultGeneratorStrategy; import javax.swing.*; import java.io.File; import java.util.ArrayList; import java.util.List; public class Test { @org.junit.jupiter.api.Test public void test() throws Exception { List<String> warnings = new ArrayList<String>(); boolean overwrite = true; File configFile = new File("H:\\TestTable\\LAST\\LAST\\PageSystem\\src\\main\\resources\\generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,callback,warnings); myBatisGenerator.generate(null); } } 这个是配置文件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 配置全局属性 --> <settings> <!-- 使用jdbc的getGeneratedKeys获取数据库自增主键值 --> <setting name="useGeneratedKeys" value="true" /> <!-- 使用列别名替换列名 默认:true --> <setting name="useColumnLabel" value="true" /> <!-- 开启驼峰命名转换:Table{create_time} -> Entity{createTime} --> <setting name="mapUnderscoreToCamelCase" value="true" /> </settings> <typeAliases> <package name="com.pojo"></package> </typeAliases> <!--<property name="mapperLocations" value="classpath:mapper/*"></property>--> <!--<mappers>--> <!--<mappers>--> <!--<mapper resource="mapper/GetTableDaoMapper.xml"/>--> <!--</mappers>--> <!--</mappers>--> </configuration> 今天学习mybatis想使用代码生成器生成代码,但是一直报这个错,网上也找了一些相关的错误,但是都没能解决问题,这里大神云集,希望问题能被解决,多谢。
java.sql.SQLException: ORA-01006: 绑定变量不存在
错误显示 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:242) at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:554) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1478) at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:677) at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2371) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2660) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:387) at cn.ntt.Dao.InfoDao.searchInfo(InfoDao.java:91) at cn.ntt.servlet.InfoServlet.doPost(InfoServlet.java:96) at cn.ntt.servlet.InfoServlet.doGet(InfoServlet.java:21) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at cn.ntt.Util.EncodingFilter.doFilter(EncodingFilter.java:44) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Dao里的代码 public List<Info> searchInfo(String sqlvalue,String subsql,String type,int start,int end){ List<Info> list = new ArrayList<Info>(); Connection conn=null; PreparedStatement ps=null; ResultSet rs =null; try { conn = JdbcUtil.getConn(); String sql="SELECT * FROM T_INFO "; if(!"".equals(subsql)&&subsql!=null){ if(subsql.equals("info_content")){ sql+="WHERE INFO_CONTENT "; }else if(subsql.equals("info_phone")){ sql+="WHERE INFO_PHONE "; }else if(subsql.equals("info_email")){ sql+="WHERE INFO_EMAIL "; }else if(subsql.equals("id")){ sql+="WHERE ID "; }else if(subsql.equals("info_title")){ sql+="WHERE INFO_TITLE "; }else if(subsql.equals("info_linkman")){ sql+="WHERE INFO_LINKMAN "; }if(type.equals("all")){ sql += " = '" + sqlvalue + "'"; }else if(type.equals("like")){ sql += "like '%" + sqlvalue + "%' "; } sql+=" ORDER BY ID DESC"; sql="SELECT * FROM(SELECT U.*, ROWNUM RN FROM("+sql+")"+ "U WHERE ROWNUM<=?) A WHERE A.RN>=?"; } //编译SQL语句 ps=conn.prepareStatement(sql); ps.setInt(1, end); ps.setInt(2,start); rs = ps.executeQuery();//结果集,只有遍历时才用 while(rs.next()){ Info info =new Info(); info.setId(rs.getInt("ID")); info.setInfo_type(rs.getString("INFO_TYPE")); info.setInfo_title(rs.getString("INFO_TITLE")); info.setInfo_content(rs.getString("INFO_CONTENT")); info.setInfo_phone(rs.getString("INFO_PHONE")); info.setInfo_linkman(rs.getString("INFO_LINKMAN")); info.setInfo_email(rs.getString("INFO_EMAIL")); list.add(info); } }catch(SQLException e){ e.printStackTrace(); }finally{ JdbcUtil.closeConn(rs, ps, conn); } return list; } Servlet的代码 else if("search".equals(flag)){ //获取left.jsp中关键字查询和条件查询 String sqlvalue=req.getParameter("sqlvalue"); String subsql=req.getParameter("subsql"); String type=req.getParameter("type"); List<Info> list=infoDao.search(sqlvalue, subsql, type); int total=list.size();//总共的条数 int totalPage=0;//总共的页数 if(total%5==0){ totalPage=total/5; }else{ totalPage=total/5+1; } /*totalPage=total%3==0?total/3:total/3+1;*/ String cp=req.getParameter("currPage"); if(cp==null||cp==""){ cp="1"; } int currPage=Integer.parseInt(cp); if(currPage<1){ currPage=1; }else if(currPage>totalPage){ currPage=totalPage; } int start=0;//开始的条数 int end=0;//结束的条数 start=(currPage-1)*5+1; end=currPage*5; //存放进searchInfo这个Dao方法里 List<Info> infolist=infoDao.searchInfo(sqlvalue, subsql, type, start, end); req.setAttribute("start", start); req.setAttribute("end", end); req.setAttribute("currPage", currPage); req.setAttribute("totalPage", totalPage); req.setAttribute("infolist", infolist); req.setAttribute("infolist", infolist); req.getRequestDispatcher("pages/show/searchshow.jsp").forward(req, resp); }
java调用存储过程来分页:java.sql.SQLException: Ref 游标无效
<p>请各位帮忙,我看了两天也看出怎么错了。</p> <p> </p> <p>plsql代码:</p> <p> </p> <p>SQL&gt; create or replace package testpackage as        <span style="color: #978b68;">--创建包用来放游标<br></span>  2  type test_cursor is ref cursor;                               <span style="color: #978b68;">--定义的游标test_cursor,ref curosr用法还不是很熟<br></span>  3  end testpackage;<br>  4  /</p> <p>Package created</p> <p> </p> <p>SQL&gt; create or replace procedure fenye(<br>  2                                    v_tablename in varchar2,    <span style="color: #978b68;">--输入的表名,根据不同的表来分页<br></span>  3                                    v_pagenow   in number,      <span style="color: #978b68;">--分页时当前页码<br></span>  4                                    v_pagesize  in number,       <span style="color: #978b68;">--每页的页数<br></span>  5                                    v_mypagecount out number,        <span style="color: #978b68;">--计算出一共多少页<br></span>  6                                    v_myrows          out number,        <span style="color: #978b68;">--计算表中一共多少行<br></span>  7                                    p_cursor out testpackage.test_cursor      <span style="color: #978b68;">--要输出的游标<br></span>  8                                    )<br>  9  is<br> 10    v_sql   varchar2(1000);<br> 11    v_begin number:=(v_pagenow-1)*v_pagesize+1;   <span style="color: #978b68;">--计算初始页,既从哪页开始<br></span> 12    v_end   number:=v_pagenow*v_pagesize;              <span style="color: #978b68;">--计算结束页,既从哪页结束</span></p> <p><span style="color: #978b68;"><br></span> 13  begin       --<br> 14    v_sql:='select *<br> 15                 from   (select b.*,<br> 16                                      rownum as rn<br> 17                            from  (select *<br> 18                                      from '||v_tablename||'<br> 19                                      order by sal desc) b<br> 20                            where rownum&lt;='||v_end||')<br> 21                where  rn&gt;='||v_begin;</p> <p><br> 22    open p_cursor for v_sql;</p> <p><br> 23    v_sql:='select count(*) from '||v_tablename;<br> 24    execute immediate v_sql into v_myrows;</p> <p><br> 25    if mod(v_myrows,v_pagesize)=0 then<br> 26    v_mypagecount:=v_myrows/v_pagesize;<br> 27    else<br> 28    v_mypagecount:=v_myrows/v_pagesize+1;<br> 29    end if;</p> <p><br> 30    close p_cursor;<br> 31  end;<br> 32  /</p> <p>Procedure created</p> <p> </p> <p>java代码:</p> <p> </p> <p><span style="color: #a9b34b;">import java.sql.*;</span></p> <p> </p> <p><span style="color: #a9b34b;">public class TestProcedure<br>{ <br>  public static void main(String args[]){<br>     try{<br>         <br>         Class.forName("oracle.jdbc.driver.OracleDriver");<br>         Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:MYORACLE","SCOTT","TIGER");</span></p> <p><span style="color: #a9b34b;"> <p><br>         CallableStatement call=con.prepareCall("{call fenye(?,?,?,?,?,?)}");<span style="color: #000000;">--分页过程的6个参数</span></p> <p><span style="color: #000000;"><br></span>         call.setString(1,"emp");<br>         call.setInt(2,3);<br>         call.setInt(3,2);</p> <p><br>         call.registerOutParameter(4,oracle.jdbc.OracleTypes.INTEGER);<br>         call.registerOutParameter(5,oracle.jdbc.OracleTypes.INTEGER);<br>         call.registerOutParameter(6,oracle.jdbc.OracleTypes.CURSOR);-<span style="color: #000000;">-输出的游标</span></p> <p><br>         call.execute();</p> <p><br>         int rowNum=call.getInt(4);<br>         int pageCount=call.getInt(5);</p> <p><br>        //System.out.println("rowNum:"+rowNum);<br>        //System.out.println("pageCount:"+pageCount);</p> <p><br>         ResultSet rs=(ResultSet) ((OracleCallableStatement)call).getObject(6);   <span style="color: #000000;">--提示有错误</span></p> <p> </p> <span style="color: #a9b34b;"> <p> </p> </span></span></p> <p><span style="color: #a9b34b;">         while(rs.next()){<br>             System.out.println("编号:"+rs.getInt(1)+" "+"名字:"+rs.getString(2));<br>        }<br>         rs.close();<br>         con.close();<br>         call.close();<br>     }<br>     catch(Exception e){<br>         e.printStackTrace();<br>     }<br>  }<br>}</span></p> <p> </p> <p><span style="color: #000000;">错误Exception:</span></p> <p> </p> <p>rowNum:7<br>pageCount:14</p> <p><br>java.sql.SQLException: Ref 游标无效<br> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)<br> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)<br> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)<br> at oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:3211)<br> at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:5036)<br> at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4964)<br> at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:586)<br> at com.neusoft.TestProcedure.main(TestProcedure.java:26)</p> <p> </p>
java.sql.SQLException ORA-12505
Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connection descriptor used by the client was: 172.22.246.26:1521:oracle ora - 12505,TNS:侦听器目前并不知道SID给定的连接描述符 连接客户端所使用的描述符是: 172.22.246.26:1521:甲骨文 小弟对于oracle数据库的使用不够熟悉,报了这个错误,我在网上查是什么admin文件夹中的tnsnames.ora有问题,但是,我其他项目中的数据库连接使用都没有问题
我的tomcat无法连接到Oracle数据库
每次都会报这个错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kenConfigurer' defined in class path resource [org/kuali/rice/config/RiceServiceSpringBeans.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initializer' defined in class path resource [org/kuali/rice/ken/config/KENLocalSpringBeans.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springTxDataSource.rice.ksb.scheduler': java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:oracle:thin:@10.254.9.30:1521:orcl : IO 错误: Software caused connection abort: recv failed [See nested exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:oracle:thin:@10.254.9.30:1521:orcl : IO 错误: Software caused connection abort: recv failed] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 我在宿舍没有问题,在教室就会连不上数据库,这个难道是网络的问题么?求各位大神指点
java数据库,出现java.lang.ClassNotFoundException 问题
package S; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; public class JDBCS { String url = "jdbc:mysql://localhost:3307/ty10"; String name = "root"; String password = "mysql"; Connection conn = null; PreparedStatement pps=null; ResultSet rs = null; JDBCS() { try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(url,name,password); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void update(String sql,String[] val){ try { pps = conn.prepareStatement(sql); for (int i = 0; val!=null && i < val.length; i++) { pps.setString(i+1, val[i]); } pps.executeUpdate(); }catch (SQLException e) { e.printStackTrace(); } } ArrayList<HashMap<String ,String>> queryToList(String sql ,String[] val){ rs=query(sql,val); ArrayList<HashMap<String ,String>> list = new ArrayList<HashMap<String,String>>(); try { ResultSetMetaData mt = rs.getMetaData();//结果集结构对象(有啥字段,类型,长度。。。) while(rs.next()){ HashMap<String ,String> map = new HashMap<String ,String>(); for (int i = 0; i < mt.getColumnCount(); i++) {//取所有字段 String name = mt.getColumnName( i+1 );//获取列名 map.put(name, rs.getString(name)); } list.add(map); } } catch (SQLException e) { e.printStackTrace(); } return list ; } ResultSet query(String sql ,String[] val){ try { pps = conn.prepareStatement(sql); for (int i = 0; val!=null && i < val.length; i++) { pps.setString(i+1, val[i]); } rs = pps.executeQuery(); return rs ; }catch (SQLException e) { e.printStackTrace(); } return null; } void close(){ try { rs.close(); } catch (SQLException e2) { e2.printStackTrace(); } try { pps.close(); } catch (SQLException e1) { e1.printStackTrace(); } try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } 运行后错误提示 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at S.JDBCS.<init>(JDBCS.java:22) at S.student2.main(student2.java:9) Exception in thread "main" java.lang.NullPointerException at S.JDBCS.query(JDBCS.java:81) at S.student2.main(student2.java:10)
用java+sql server2000做的系统,怎样用java+sql server 2005运行
我在网上下载了一个图书馆管理系统,是用java+sql server2000做的,但是怎样用java+sql server 2005运行呢? 运行的时候出现了如下的错误: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:221) at com.lzw.dao.Dao.<init>(Dao.java:36) at com.lzw.dao.Dao.executeQuery(Dao.java:48) at com.lzw.dao.Dao.check(Dao.java:88) at com.lzw.iframe.BookLoginIFrame$BookLoginAction.actionPerformed(BookLoginIFrame.java:40) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.AbstractButton.doClick(AbstractButton.java:356) at com.lzw.iframe.BookLoginIFrame$1.keyPressed(BookLoginIFrame.java:114) at java.awt.Component.processKeyEvent(Component.java:6463) at javax.swing.JComponent.processKeyEvent(JComponent.java:2829) at java.awt.Component.processEvent(Component.java:6282) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727) at java.awt.Component.dispatchEventImpl(Component.java:4731) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:688) at java.awt.EventQueue$3.run(EventQueue.java:686) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:702) at java.awt.EventQueue$4.run(EventQueue.java:700) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:699) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.lzw.dao.Dao.executeQuery(Dao.java:49) at com.lzw.dao.Dao.check(Dao.java:88) at com.lzw.iframe.BookLoginIFrame$BookLoginAction.actionPerformed(BookLoginIFrame.java:40) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.AbstractButton.doClick(AbstractButton.java:356) at com.lzw.iframe.BookLoginIFrame$1.keyPressed(BookLoginIFrame.java:114) at java.awt.Component.processKeyEvent(Component.java:6463) at javax.swing.JComponent.processKeyEvent(JComponent.java:2829) at java.awt.Component.processEvent(Component.java:6282) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727) at java.awt.Component.dispatchEventImpl(Component.java:4731) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:688) at java.awt.EventQueue$3.run(EventQueue.java:686) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:702) at java.awt.EventQueue$4.run(EventQueue.java:700) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:699) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
请大神帮忙这种错误是什么原因造成的
严重: Servlet.service() for servlet [springServlet] in context with path [/fzbxxh] threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型 ; uncategorized SQLException for SQL []; SQL state [null]; error code [17004]; 无效的列类型; nested exception is java.sql.SQLException: 无效的列类型] with root cause java.sql.SQLException: 无效的列类型
JBOSS7部署EAR出现 java.lang.VerifyError
EAR中,有EJB和WAR工程,war中的servlet调用EJB提示下面错误: GatewayService threw exception: java.lang.VerifyError: (class: xxx/xxx/xxx, method: init signature: ()V) Incompatible object argument for function call 在EAR的LIB目录下,存在包含xxx/xxx/xxx的jar,并且初步进行check,没有发现存在相同名称的类。xxx/xxx/xx部分代码如下: import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.xerces.parsers.AbstractDOMParser; import org.apache.xerces.parsers.DOMParser; import org.apache.xml.serialize.BaseMarkupSerializer; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.hibernate.lob.SerializableBlob; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; import slot.base64.Base64Encoder; import slot.common.Log; import slot.exception.GeneralException; import slot.util.DateUtil; public class MessageObject implements MsgConstant, Serializable { private DOMParser parser = new DOMParser(); private Document document; private DocumentBuilder builder = null; private Element root; private Node header = null; private Node extAttrs = null; private Node request = null; private Node response = null; private Node body = null; private boolean bindingRequest = false; static Class class$0; public MessageObject() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { this.builder = factory.newDocumentBuilder(); DOMImplementation impl = this.builder.getDOMImplementation(); this.document = impl.createDocument(null, "Message", null); this.root = this.document.getDocumentElement(); this.header = setChildValueByName(this.root, "", "Header"); this.body = setChildValueByName(this.root, "", "Body"); this.extAttrs = setChildValueByName(this.header, "", "ext_attributes"); this.request = setChildValueByName(this.body, "", "request"); this.response = setChildValueByName(this.body, "", "response"); impl = null; this.builder = null; } catch (Exception e) { e.printStackTrace(); } } public MessageObject(byte[] bytesinput) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(bytesinput); InputSource ins = new InputSource(bais); ins.setEncoding("UTF-8"); this.parser.parse(ins); bais.close(); ins = null; init(); } 在调用 MessageObject(byte[] bytesinput)构造函数出现上面的错误,无解。。。
java连接sqlserver2000数据库总失败
运行的错误都是java.sql.SQLException:No suitable driver found for jdbc:qlserver://.....是什么问题,是路径代码输错了还是数据库驱动安错地方了,,,求助
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
【资源】一个C/C++开发工程师的学习路线(已经无路可退,唯有逆风飞翔)【内附资源页】
声明: 1)该文章整理自网上的大牛和专家无私奉献的资料,具体引用的资料请看参考文献。 2)本文仅供学术交流,非商用。所以每一部分具体的参考资料并没有详细对应。如果某部分不小心侵犯了大家的利益,还望海涵,并联系博主删除。 3)博主才疏学浅,文中如有不当之处,请各位指出,共同进步,谢谢。 4)此属于第一版本,若有错误,还需继续修正与增删。还望大家多多指点。大家都共享一点点,一起为祖国科研的推进...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
20道你必须要背会的微服务面试题,面试一定会被问到
写在前面: 在学习springcloud之前大家一定要先了解下,常见的面试题有那块,然后我们带着问题去学习这个微服务技术,那么就会更加理解springcloud技术。如果你已经学了springcloud,那么在准备面试的时候,一定要看看看这些面试题。 文章目录1、什么是微服务?2、微服务之间是如何通讯的?3、springcloud 与dubbo有哪些区别?4、请谈谈对SpringBoot 和S...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
神级宝库!GitHub 标星 1.2w+,Chrome 最天秀的插件都在这里啦!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个沉迷 Chrome 不能自拔的蒟蒻… 作为一个在远古时代用过什么 IE、360、猎豹等浏览器的资深器哥,当我第一次了解 Chrome 的时候,就被它的美貌给吸引住了… 就在我用了一段时间之后,我坚决的卸载了电脑上其它碍眼的浏览器,并觉得在之前的搬砖生涯中,我不配当哥,我只配是个沙雕… ...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
张朝阳回应迟到 1 分钟罚 500:资本家就得剥削员工
loonggg读完需要2分钟速读仅需 1 分钟大家我,我是你们的校长。前几天,搜狐的董事局主席兼 CEO 张朝阳和搜狐都上热搜了。原因很简单,就是搜狐出了“考勤新规”。一封搜狐对员工发布...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
立即提问