小弟的代码总是说非法的表达式开始求大神

import java.sql.*;
public class TestPreparedStatement {

public static void main(String[] args) {
    add("12","GTA","动作");

static void add(String string;String string2;String string3) {
    Connection conn=null;
    PreparedStatement stmt=null;
    try{
        Class.forName("com.mysql.jdbc.Driver");
        conn=DriverManager.getConnection("jdbc:mysql://localhost/test?"+
        "user=root&password=710309471&useSSL=true");
        String sql="insert games values (?,?,?)";
        stmt=conn.prepareStatement(sql);
        stmt.setString(1,string);
        stmt.setString(2, string2);
        stmt.setString(3, string3);
        System.out.println(sql);
        stmt.executeUpdate();
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }catch(SQLException ex){
            System.out.println("SQLException"+ex.getMessage());
            System.out.println("SQLState"+ex.getSQLState());
            System.out.println("VendorError"+ex.getErrorCode());
        }finally{
            try{
            if(conn!=null){
                conn.close();
                conn=null;
            }
            }catch(SQLException e){
                e.printStackTrace();
            }
        }
   }
}

}

有几处错误,给你给了一下,看看吧。第一、add方法中参数之间用 “,”隔开,不是“;”。第二、你把add方法写到main里面去了,写在外面
public class Test {
public static void main(String[] args) {
add("12","GTA","动作");
}
static void add(String string,String string2,String string3) {
Connection conn=null;
PreparedStatement stmt=null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost/test?"+
"user=root&password=710309471&useSSL=true");
String sql="insert games values (?,?,?)";
stmt=conn.prepareStatement(sql);
stmt.setString(1,string);
stmt.setString(2, string2);
stmt.setString(3, string3);
System.out.println(sql);
stmt.executeUpdate();
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException ex){
System.out.println("SQLException"+ex.getMessage());
System.out.println("SQLState"+ex.getSQLState());
System.out.println("VendorError"+ex.getErrorCode());
}finally{
try{
if(conn!=null){
conn.close();
conn=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
}

对对,马虎了,疏忽了大括号了,

然后注意编码规范,可以看看阿里开发手册。养成好的编码习惯!