我想将数据提取到数据库但有错误

时间:2018-01-25 11:57:02

标签: java

我创建了一个注册表单并将数据保存在数据库中,但它没有检索表:

以下是代码:

>>> sqlContext.sql("""select name, age, car.name as car, car.models from json.`data.json` lateral view outer explode(cars) v1 as car""").show()
+-----+---+----+--------------------+
| name|age| car|              models|
+-----+---+----+--------------------+
| John| 30|Ford|[Fiesta, Focus, M...|
| John| 30| BMW|       [320, X3, X5]|
| John| 30|Fiat|        [500, Panda]|
|Dough| 90|null|                null|
+-----+---+----+--------------------+

我尝试运行时遇到此错误:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
     try {
        //con = DriverManager.getConnection("jdbc:mysql://localhost:3306/studreg","root","");
        String sql="select * from newdata where srno=?";
        ResultSet resultSet =null;
        pst=con.prepareStatement(sql);
        pst.setText(1,search.getText());  
        rs =pst.executeQuery();
        if(rs.next()){
            String add1;
             add1 = rs.getString("srno");
            srno.setText(add1);
            String add2=rs.getString("name");
            name.setText(add2);
            String add3=rs.getString("email");
            email.setText(add3);
            String add4=rs.getString("password");
            password.setText(add4);
            String add5=rs.getString("mobleno");
            mobileno.setText(add5);
            String add6=rs.getString("gender");
            gender.setText(add6);
            String add7=rs.getString("country");
            country.setText(add7);
            String add8=rs.getString("refrence");
            refrence.setText(add8);
            String add9=rs.getString("select");
            select.setText(add9);>

1 个答案:

答案 0 :(得分:0)

此消息:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol symbol: class preparedStatment location: class newframe.DataSave

可能意味着您应该将其添加到源代码中:

import java.sql.PreparedStatement;