现在可以用python向数据库插入数据,但是我现在想用java调取这个py文件插入数据,一直没反应,也不报错。
代码如下:
import org.python.core.Py;
import org.python.core.PySystemState;
import org.python.util.PythonInterpreter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class py {
public static void main(String[] args) throws IOException {
try{
System.out.println("start");
Process pr = Runtime.getRuntime().exec("python C:\Users\神奇的刘dd\PycharmProjects\untitled\TestMysql.py");
System.out.println("123");
BufferedReader in = new BufferedReader(new
InputStreamReader(pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
pr.waitFor();
System.out.println("end");
} catch (Exception e){
e.printStackTrace();
}
}
}
求高人指点。