El error me da justo al ejecutar el programa, y dice:
Exception in thread "main" java.lang.NoSuchMethodError: main
No dice nada mas!
Espero que con eso me podáis dar algo que revisar. :-)
Exception in thread "main" java.lang.NoSuchMethodError: main
No dice nada mas!
Espero que con eso me podáis dar algo que revisar. :-)
¿Como has escrito el cuerpo del main?. A mí me dió ese error ayer mismo, el problema fué que no había puesto la clausula static en el main
Hola:
Yo tengo el mismo problema pero si tengo el static que es lo que puede ser
les mando el scrip para que chequen que es lo que tengo mal
import java.io.*;
import java.sql.*;
import java.util.*;
public class insert2 {
public static void main(String DRIVER){
// public static void main(String DRIVER){
System.out.println("prueba de JDBC");
Connection con = null;
// "org.gjt.mm.mysql.Driver"
String driver = DRIVER;
//// String driver = "org.gjt.mm.mysql.Driver";
String url = "jdbc:mysql://192.168.0.200/PRUEBA";
String name = "";
String password = "";
try {
Class.forName(driver);
} catch(Exception e) {
System.out.println("Error respecto al driver " + driver);
System.out.println(e.getMessage());
System.exit(0);
}
try {
con = DriverManager.getConnection(url, name, password);
} catch(Exception e) {
System.out.println("Error de acceso al url " + url + " para usuario" + name);
System.out.println(e.getMessage());
System.exit(0);
}
//String sql = "INSERT INTO TABLA VALUES (Ross, Qro, 2-xxx, is1)";
String sql = "INSERT INTO TABLA " +
"VALUES ('yarethe2','qro','222','is1')";
/* String NOMBRE= "Ross",
CITY= "QRO",
TEL= "2-XX",
EMPRESA= "IS1";
String sql = "INSERT INTO TABLA ";
sql += " VALUES(" + quote(NOMBRE) + ", ";
sql += quote(CITY) + ", ";
sql += quote(TEL) + ", ";
sql += quote(EMPRESA) + ");";*/
// stmt.executeQuery(sql);
try {
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
/* con.setAutoCommit(false);
stmt.addBatch("INSERT INTO TABLA" +
"VALUES('rOSS', 'QRO', '2-XXX', 'IS1')");
stmt.addBatch("INSERT INTO TABLA" +
"VALUES('OTRO', 'OTRA', 'OTRO', 'OTRA')");
int [] updateCounts = stmt.executeBatch(); */
stmt.executeUpdate(sql);
} catch(Exception e) {
// System.out.println("Error ejecutando " + sql);
System.out.println(e.getMessage());
System.exit(0);
}
}
}
Yo tengo el mismo problema pero si tengo el static que es lo que puede ser
les mando el scrip para que chequen que es lo que tengo mal
import java.io.*;
import java.sql.*;
import java.util.*;
public class insert2 {
public static void main(String DRIVER){
// public static void main(String DRIVER){
System.out.println("prueba de JDBC");
Connection con = null;
// "org.gjt.mm.mysql.Driver"
String driver = DRIVER;
//// String driver = "org.gjt.mm.mysql.Driver";
String url = "jdbc:mysql://192.168.0.200/PRUEBA";
String name = "";
String password = "";
try {
Class.forName(driver);
} catch(Exception e) {
System.out.println("Error respecto al driver " + driver);
System.out.println(e.getMessage());
System.exit(0);
}
try {
con = DriverManager.getConnection(url, name, password);
} catch(Exception e) {
System.out.println("Error de acceso al url " + url + " para usuario" + name);
System.out.println(e.getMessage());
System.exit(0);
}
//String sql = "INSERT INTO TABLA VALUES (Ross, Qro, 2-xxx, is1)";
String sql = "INSERT INTO TABLA " +
"VALUES ('yarethe2','qro','222','is1')";
/* String NOMBRE= "Ross",
CITY= "QRO",
TEL= "2-XX",
EMPRESA= "IS1";
String sql = "INSERT INTO TABLA ";
sql += " VALUES(" + quote(NOMBRE) + ", ";
sql += quote(CITY) + ", ";
sql += quote(TEL) + ", ";
sql += quote(EMPRESA) + ");";*/
// stmt.executeQuery(sql);
try {
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
/* con.setAutoCommit(false);
stmt.addBatch("INSERT INTO TABLA" +
"VALUES('rOSS', 'QRO', '2-XXX', 'IS1')");
stmt.addBatch("INSERT INTO TABLA" +
"VALUES('OTRO', 'OTRA', 'OTRO', 'OTRA')");
int [] updateCounts = stmt.executeBatch(); */
stmt.executeUpdate(sql);
} catch(Exception e) {
// System.out.println("Error ejecutando " + sql);
System.out.println(e.getMessage());
System.exit(0);
}
}
}