select * into query executeUpdate()

时间:2016-05-02 15:17:19

标签: java sql postgresql jdbc

我正在使用带有jdbc的postgresql。当我尝试使用以下代码行时,它没有执行。

int suc = stins.executeUpdate("select * into kmeans_cluster"+i+" from kmeans_emp where sno="+sno);              
if(suc>0)System.out.println("success");
else System.out.println("fail");

输出始终是“失败”。

这是代码段。

package kmeans;
import java.sql.*;
import java.util.*;

public class Kmeans{
    Connection con;Statement st,stins;ResultSet rs;Scanner s;
    public Kmeans(){
        try{
            con = DriverManager.getConnection("jdbc:postgresql://localhost/kmeans","postgres","naren");
            st = con.createStatement();
            stins = con.createStatement();
            s=new Scanner(System.in);
            System.out.println("Enter no.of clusters");
            int nc = s.nextInt();
            float cc[]=new float[nc];
            rs = st.executeQuery("select * from kmeans_emp");
            for(int i=0;i<nc;i++){
                rs.next();
                cc[i]=Float.parseFloat(rs.getString(3));
                int sno = Integer.parseInt(rs.getString(1));                
                int suc = stins.executeUpdate("select * into kmeans_cluster"+i+" from kmeans_emp where sno="+sno);              
                if(suc>0)System.out.println("success");
                else System.out.println("fail");
            }
            float a,b;
            .
            .
            ...

0 个答案:

没有答案