Rodrigo Guedes de Souza 0 Posted March 14, 2019 Report Share Posted March 14, 2019 Saudações, Estou criando um programa com base Java para cadastro de clientes. Para armazenar os dados obtidos, queria criar um banco de dados no MYSQL, para assim "juntar" as duas coisas para compilarem juntas. Todavia não estou conseguindo "juntar" o java com o banco de dados MYSQL. Consigo compilar o programa em java normalmente, o JPanel abre sem problemas, o único problema é na hora de "cadastrar" o usuário. Espero resposta Abraços. Segue abaixo o erro após tentar cadastrar o usuário: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property. at factory.ConnectionFactory.getConnection(ConnectionFactory.java:16) at dao.UsuarioDAO.<init>(UsuarioDAO.java:14) at gui.UsuarioGUI.jButton1ActionPerformed(UsuarioGUI.java:194) at gui.UsuarioGUI.access$000(UsuarioGUI.java:14) at gui.UsuarioGUI$1.actionPerformed(UsuarioGUI.java:61) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6533) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6298) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) at java.awt.Container.dispatchEventImpl(Container.java:2280) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Caused by: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1784) at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3499) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2384) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at factory.ConnectionFactory.getConnection(ConnectionFactory.java:13) Link to post Share on other sites
M6 149 Posted March 15, 2019 Report Share Posted March 15, 2019 Boas. Não podes compilar a base de dados MySQL, é um servidor que está a correr algures (não interessa onde). O que tens de fazer é juntar ao teu programa a biblioteca Java de acesso ao MySQL e colocá-la no classpath. Pelo que vejo do erro, o teu problema nem é esse. O teu problema parece ser de configuração, pois se leres a mensagem de erro "Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property." vais-te aperceber que isso já é um erro derivado da própria comunicação com a base de dados. Assim sendo, a primeira coisa que tens de fazer é verificar se estás a usar a biblioteca/conector certo/mais recente e em caso afirmativo leres a documentação para saberes mais sobre o erro e o "characterEncoding" - que parece ser um erro de encoding diferente entre a base de dados e o que está configurado na ligação a partir do Java. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to post Share on other sites
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