Jump to content

Recommended Posts

Posted (edited)

eu fiz este código:

package teste;

import java.sql.*;

public class BDconnection {
public static void main(String[]args){
String dataSourceName = "tesSqlDb";
String dbUrl = "Jdbc:odbc:" + dataSourceName;


try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbUrl,"","");

Statement s = con.createStatement();

s.execute("Create table School12(Grade,Remark text)");

s.close();
con.close();
}catch(Exception e){
System.out.println("Clientes" +e);
}
}

}

Mas quando o vou a executar aparece-me este erro, alguém mo pode explicar ou dizer uma maneira mais simples de conectar java a sql?

Clientesjava.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.5.24]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Remark text)' at line 1

Obrigado

Edited by Baderous
geshi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.