| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 808 人关注过本帖
标题:eclipse与MYSQL数据库的链接问题
只看楼主 加入收藏
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
结帖率:90.24%
收藏
已结贴  问题点数:20 回复次数:9 
eclipse与MYSQL数据库的链接问题
package test;
import javax.swing.JFrame;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

import java.awt.CardLayout;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.ImageIcon;

import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class TeacherChint extends JFrame{
    //主窗体的界面设计
   
    private String host; //host=数据库主机IP+“:”+端口号
    String coll_id; //声明学院编号的引用
   
    //创建各个树的节点
    private DefaultMutableTreeNode dmtnRoot=//创建根节点
            new DefaultMutableTreeNode(new MyNode("操作选项","0"));
    private DefaultMutableTreeNode dmtn1=//创建系统选项节点
            new DefaultMutableTreeNode(new MyNode("系统选项","1"));
    private DefaultMutableTreeNode dmtn2=//创建学生信息管理节点
            new DefaultMutableTreeNode(new MyNode("学生信息管理","2"));
    private DefaultMutableTreeNode dmtn3=//创建课程管理节点
            new DefaultMutableTreeNode(new MyNode("课程管理","3"));
    private DefaultMutableTreeNode dmtn4=//创建班级设置节点
            new DefaultMutableTreeNode(new MyNode("班级设置","4"));
    private DefaultMutableTreeNode dmtn11=//创建退出节点
            new DefaultMutableTreeNode(new MyNode("退出","11"));
    private DefaultMutableTreeNode dmtn13=//创建密码修改节点
            new DefaultMutableTreeNode(new MyNode("密码修改","13"));
    private DefaultMutableTreeNode dmtn21=//创建新生报到节点
            new DefaultMutableTreeNode(new MyNode("新生报到","21"));
    private DefaultMutableTreeNode dmtn22=//创建学生信息查询节点
            new DefaultMutableTreeNode(new MyNode("学生信息查询","22"));
    private DefaultMutableTreeNode dmtn221=//创建基本信息查询节点
            new DefaultMutableTreeNode(new MyNode("基本信息查询","221"));
    private DefaultMutableTreeNode dmtn222=//创建成绩查询节点
            new DefaultMutableTreeNode(new MyNode("成绩查询","222"));
    private DefaultMutableTreeNode dmtn31=//创建开课选项设置节点
            new DefaultMutableTreeNode(new MyNode("开课选项设置","31"));
    private DefaultMutableTreeNode dmtn32=//创建课程成绩录入节点
            new DefaultMutableTreeNode(new MyNode("课程成绩录入","32"));
    private DefaultMutableTreeNode dmtn34=//创建添加课程节点
            new DefaultMutableTreeNode(new MyNode("添加课程","34"));
    private DefaultMutableTreeNode dmtn42=//创建增加班级节点
            new DefaultMutableTreeNode(new MyNode("增加班级","42"));
    private DefaultTreeModel dtm=new DefaultTreeModel(dmtnRoot);//创建根节点
    private JTree jt=new JTree(dtm);//创建树状列表控件
    private JScrollPane jspz=new JScrollPane(jt);//创建滚动窗口
    private JPanel jpy=new JPanel();//创建面板
    private JSplitPane jspl=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jspz,jpy);//创建分割窗格
    //声明功能模块引用
    private ChangePwdTeacher ch;
    private NewStu newstu;
    private TeacherSearchInfo ts;
    private StuScore ss;
    private Welcome wel;
    private NewClass newclass;
    CardLayout c1;//声明卡片布局引用
    public TeacherChint(String coll_id,String host) {
        this.host=host;
        this.coll_id=coll_id;
        this.initialTree();//初始化树状列表控件
        this.initialPanel();//创建各功能模块对象
        this.addListener();//为节点注册监听器
        this.initialJpy();//初始化面板
        this.initialFrame();//初始化主窗体
    }
   
    //主窗体的初始化方法
   
    public void initialPanel() {//初始化各功能模块
        ch = new ChangePwdTeacher(host);
        newstu = new NewStu(coll_id, host);
        ts = new TeacherSearchInfo(host);
        ss = new StuScore(host);
        wel = new Welcome("成绩管理系统");
        newclass = new NewClass(coll_id,host);
    }
    public void initialTree() {//初始化树状列表控件的方法
        dmtnRoot.add(dmtn1); dmtnRoot.add(dmtn2); dmtnRoot.add(dmtn3);//将各个节点添加到树根节点
        dmtnRoot.add(dmtn4); dmtn1.add(dmtn11); dmtn1.add(dmtn13);
        dmtn2.add(dmtn21); dmtn2.add(dmtn22); dmtn22.add(dmtn221);
        dmtn22.add(dmtn222); dmtn3.add(dmtn31); dmtn3.add(dmtn32);
        dmtn3.add(dmtn34); dmtn4.add(dmtn42);
    }
   
    public void  initialJpy() {//将各功能模块添加到面板中
        jpy.setLayout(new CardLayout());//将面板设置为卡片布局
        c1 = (CardLayout)jpy.getLayout();//得到卡片布局引用
        //各功能模块将在后面各模块的开发过程中注意添加
        jpy.add(ch,"ch");
        jpy.add(newstu,"newstu");
        jpy.add(ts,"ts");
        jpy.add(ss,"ss");
        jpy.add(wel,"wel");
        jpy.add(newclass,"newclass");
    }
   
    public void initialFrame() {//设置窗体的标题、大小及可见性
        this.add(jspl); jspl.setDividerLocation(200);//设置分割窗体的位置并添加到主窗体
        jspl.setDividerSize(4);//设置分隔条的大小
        Image image = new ImageIcon().getImage();//加载窗体图标对象
        this.setIconImage(image); this.setTitle("教师客户端");//设置窗体的图标和标题
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();//得到屏幕的Dimension对象
        
        int centerX = screenSize.width/2;//计算屏幕宽度中间像素点
        int centerY = screenSize.height/2;//计算屏幕高度中间项数点
        int w = 900;//本窗体宽度
        int h = 650;//本窗体高度
        this.setBounds(centerX-w/2,centerY-h/2-30,w,h);//设置窗体出现在屏幕中央
        this.setVisible(true);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);//窗体全屏
        
    }
   
    //注册鼠标事件监听器
    public void addListener() {//为树状列表控件注册鼠标事件监听器
        jt.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                 DefaultMutableTreeNode dmtntemp=//得到当前选中的节点对象
                    (DefaultMutableTreeNode)jt.getLastSelectedPathComponent();
                 MyNode mynode=(MyNode)dmtntemp.getUserObject();//得到自定义节点对象
                 String id= mynode.getId();//得到选中节点的名称
                 //根据id值选择显示不同的卡片
                 if(id.equals("0")) {/*欢迎界面*/
                     c1.show(jpy,"wel");
                 }
                 else if(id.equals("11")) {//退出系统
                     int i= JOptionPane.showConfirmDialog(jpy,"您确认要退出系统吗?",
                             "询问",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
                     if(i==0){System.exit(0);} }//单击确认退出系统
                 else if(id.equals("13")) { /*更改密码页面*/
                     c1.show(jpy,"ch");
                     ch.setFocus();
                 }
                 else if(id.equals("21")) {/*添加学生页面*/
                     c1.show(jpy,"newstu");
                     newstu.setFocus();
                 }
                 else if(id.equals("221")) { /*学生信息查询页面*/
                     c1.show(jpy,"ts");
                     ts.setFocus();
                 }
                 else if(id.equals("222")) { /*成绩查询页面*/
                     c1.show(jpy,"ss");
                     ss.setFocus();
                 }
                 else if(id.equals("31")) { /*选课管理界面*/}
                 else if(id.equals("32")) { /*成绩录入界面*/}
                 else if(id.equals("34"))  { /*添加课程页面*/}
                 else if(id.equals("42")) {/*添加班级页面*/
                     c1.show(jpy,"newclass");
                     newclass.setFocus();
                 }
                 }
        });
            jt.setToggleClickCount(1);//将展开节点的鼠标单击次数为1
                             
         }
        


class MyNode {
    private String values;//声明values属性
    private String id;
    public MyNode(String values, String id) {
        this.values = values;
        this.id = id;
    }
    public String toString() { return this.values;}
    public String getId() { return this.id;}
}
   
public static void main(String[] args) {
    new TeacherChint("01","127.0.0.1:3306");
  }
}
出现了一下错误,求指导!!!
java.lang.ArrayIndexOutOfBoundsException: 12
    at test.NewStu.<clinit>(NewStu.java:55)
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
com.mysql.jdbc.exceptions. Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:357)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2482)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at test.NewStu.initialConnection(NewStu.java:89)
    at test.NewStu.initialData(NewStu.java:110)
    at test.NewStu.<init>(NewStu.java:80)
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Caused by: Connection refused: connect
    at (Native Method)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:307)
    ... 20 more
java.lang.NullPointerException
    at test.NewStu.initialData(NewStu.java:113)
    at test.NewStu.<init>(NewStu.java:80)
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
com.mysql.jdbc.exceptions. Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:357)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2482)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at test.NewClass.initialConnection(NewClass.java:76)
    at test.NewClass.initialData(NewClass.java:37)
    at test.NewClass.<init>(NewClass.java:30)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Caused by: Network is unreachable: connect
    at (Native Method)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:307)
    ... 20 more
java.lang.NullPointerException
    at test.NewClass.initialData(NewClass.java:39)
    at test.NewClass.<init>(NewClass.java:30)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Exception in thread "main" java.lang.NullPointerException
    at test.NewClass.initialFrame(NewClass.java:56)
    at test.NewClass.<init>(NewClass.java:31)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
搜索更多相关主题的帖子: package import 数据库 
2015-10-01 09:49
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:20 
程序代码:
java.lang.ArrayIndexOutOfBoundsException: 12
    at test.NewStu.<clinit>(NewStu.java:55)//数组下标越界异常而且还是test包下的NewStu类里面的异常。。。
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
com.mysql.jdbc.exceptions. Communications link failure//mysq连接好像也有问题,最好测试一下

我看这个文件还是蛮多的,你单独发找不到连带错误源头

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 10:11
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
收藏
得分:0 
我改了一下,现在出现了下面的错误:
com.mysql.jdbc.exceptions. Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:357)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2482)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at test.NewStu.initialConnection(NewStu.java:89)
    at test.NewStu.initialData(NewStu.java:110)
    at test.NewStu.<init>(NewStu.java:80)
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Caused by: Connection refused: connect
    at (Native Method)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:307)
    ... 20 more
java.lang.NullPointerException
    at test.NewStu.initialData(NewStu.java:113)
    at test.NewStu.<init>(NewStu.java:80)
    at test.TeacherChint.initialPanel(TeacherChint.java:85)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
com.mysql.jdbc.exceptions. Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:357)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2482)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at test.NewClass.initialConnection(NewClass.java:76)
    at test.NewClass.initialData(NewClass.java:37)
    at test.NewClass.<init>(NewClass.java:30)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Caused by: Network is unreachable: connect
    at (Native Method)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:307)
    ... 20 more
java.lang.NullPointerException
    at test.NewClass.initialData(NewClass.java:39)
    at test.NewClass.<init>(NewClass.java:30)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
Exception in thread "main" java.lang.NullPointerException
    at test.NewClass.initialFrame(NewClass.java:56)
    at test.NewClass.<init>(NewClass.java:31)
    at test.TeacherChint.initialPanel(TeacherChint.java:89)
    at test.TeacherChint.<init>(TeacherChint.java:75)
    at test.TeacherChint.main(TeacherChint.java:187)
2015-10-01 10:18
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
连接异常,空指针异常。。。。。。
你这么发下去和自己改只是缩小改错范围

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 10:25
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
收藏
得分:0 
源代码.zip (35.4 KB)
2015-10-01 16:32
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
Login.java
conn=DriverManager.getConnection(url,user,pass);报错行前缺少这句
st=conn.createStatement();
Stattment类型变量st赋值出报错因为未实例化conn
而conn实例化红体字标记的只是参数示例具体看你的实参

其次:Login用户身份验证有问题,如果用户名输入'or true or ' 密码随便输什么也能进入

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 17:52
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
还有unused import 删掉,以及泛型没用到
其他问题等我有空改完上传吧

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 17:55
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
忘了问了,代码是自己写的吗?思路有点乱

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 17:59
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
收藏
得分:0 
有的是自己写的,有的是看书的
2015-10-01 18:43
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
以下是引用yu1543054075在2015-10-1 18:43:10的发言:

有的是自己写的,有的是看书的


恩,还好。。。改的有点吃力

剑栈风樯各苦辛,别时冰雪到时春
2015-10-01 20:36
快速回复:eclipse与MYSQL数据库的链接问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061840 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved