Pessoal esse e meu código, consigo conectar ao meu banco de dados local porem não consigo conectá-lo a banco remota da minha aplicação. Alguém pode me ajudar ?
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://protecline1.mysql.uhserver.comt?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">gabrielms</property>
<property name="hibernate.connection.password">senha</property>
<mapping resource="entity/Material.hbm.xml"/>
<mapping resource="entity/Cliente.hbm.xml"/>
<mapping resource="entity/Pedido.hbm.xml"/>
<mapping resource="entity/Funcionario.hbm.xml"/>
<mapping resource="entity/Local.hbm.xml"/>
<mapping resource="entity/TipoAtendimento.hbm.xml"/>
<mapping resource="entity/Menu.hbm.xml"/>
<mapping resource="entity/ItemPedido.hbm.xml"/>
<mapping resource="entity/Perfil.hbm.xml"/>
Tu não definiu o nome do schema que deseja acessar!
Exemplo:
jdbc:mysql://host/schema?parametros
assim faltava o nome do banco, porem continua sem funcionar.
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://protecline1.mysql.uhserver.com/protecline1?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">gabrielms</property>
<property name="hibernate.connection.password">senha</property>
Disserte um pouco mais o que seria o “sem funcionar”, poste o log de erro, assim fica mais fácil da galera ajudar!
Aparece o seguinte erro na minha pagina web
type Exception report
message Internal Server Error
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
root cause
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user ‘gabrielms’@‘10.129.62.39’ for table ‘menu’
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.
Minha classe util
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
O log acusa um erro do SQL, a falha já acontece quando tu starta a aplicação ou quando você executa uma ação?
Resolvi o problema, problema não era a conexão com banco e sim que eu estava tentando listar umas tabela inexistente; quando testei com outra tabela funcionou perfeitamente