AxOp Posted May 28, 2012 at 07:27 PM Report #458647 Posted May 28, 2012 at 07:27 PM (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 May 28, 2012 at 10:50 PM by Baderous geshi
HappyHippyHippo Posted May 28, 2012 at 08:24 PM Report #458662 Posted May 28, 2012 at 08:24 PM o teu comando SQL está errado lê este link para aprenderes a escrever o comando de criação de tabelas em SQL http://dev.mysql.com/doc/refman/5.1/en/create-table.html IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
AxOp Posted May 28, 2012 at 09:15 PM Author Report #458688 Posted May 28, 2012 at 09:15 PM ja consegui!!!! obrigado
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now