Connection zu externer MySQL-Datenbank

ceene

Erfahrenes Mitglied
Hallo ihr lieben

Ich stehe vor einem kleinen Problem und das Internet konnte mir auch nicht so wirklich weiterhelfen.
Ich möchte ein LoginBean schreiben das sich über JBoss oder auch über eine normale Connection unter Java mit einer Datenbank verbindet.
Die Besonderheit ist allerdings, dass die MySQL-Datenbank sich nicht auf dem gleichen System befindet wie der JBoss. Die Datenbank befindet sich bei 1und1.
Jetzt stellt sich die Frage, wie kann ich auf diese Datenbank in meinem Bean zugreifen?
Hab schon per google gesucht aber leider habe ich in diese Richtung nichts gefunden. Ich hoffe ihr könnt mir da etwas weiterhelfen.
 
Und wo ist der Unterschied? Deine Datenbank bei 1und1 wird ja auch ne IP haben oder?
 
Du meinst die URL? Klar geht das.

Ich frage mich immer warum man sowas nicht einfach ausprobiert statt Stunden auf eine Antwort zu warten.
 
Da muss ich dich entäuschen, ich warte nicht auf eine Antwort. :google:

Ich habe es nun genau so gemacht wie ich es im Netz gefunden habe, aber leider bekomme ich da auch einen Fehler. Vielleicht kennt ja einer das Problem?

Code:
try 
{
	Class.forName( "com.mysql.jdbc.Driver" );
	Connection con = DriverManager.getConnection( "jdbc:mysql://db1087.1und1.de:3306/db216478901", 
								user, passwort);

Leider bekomme ich noch folgende Fehlermeldung
Code:
09:48:20,625 INFO  [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)] Started in 18s:469ms
09:49:04,328 ERROR [STDERR] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1.248.767.342.312 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
09:49:04,328 ERROR [STDERR] 	at java.sql.DriverManager.getConnection(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.sql.DriverManager.getConnection(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at ejb.HPLoginBean.checkLogin(HPLoginBean.java:28)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
09:49:04,328 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:49:04,328 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
09:49:04,328 ERROR [STDERR] 	at $Proxy72.checkLogin(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at org.apache.jsp.Unterseiten.formular_005fdemo_jsp._jspService(formular_005fdemo_jsp.java:206)
09:49:04,328 ERROR [STDERR] 	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
09:49:04,328 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
09:49:04,328 ERROR [STDERR] 	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
09:49:04,328 ERROR [STDERR] 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
09:49:04,328 ERROR [STDERR] 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
09:49:04,328 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:49:04,328 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
09:49:04,328 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
09:49:04,328 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
09:49:04,328 ERROR [STDERR] 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
09:49:04,328 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
09:49:04,328 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
09:49:04,328 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
09:49:04,328 ERROR [STDERR] 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
09:49:04,328 ERROR [STDERR] 	at java.lang.Thread.run(Unknown Source)
09:49:04,328 ERROR [STDERR] Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1.248.767.342.312 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
09:49:04,328 ERROR [STDERR] 	... 69 more
09:49:04,328 ERROR [STDERR] Caused by: java.net.UnknownHostException: db1087.1und1.de
09:49:04,328 ERROR [STDERR] 	at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
09:49:04,328 ERROR [STDERR] 	at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.net.InetAddress.getAddressFromNameService(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.net.InetAddress.getAllByName0(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.net.InetAddress.getAllByName(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at java.net.InetAddress.getAllByName(Unknown Source)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:243)
09:49:04,328 ERROR [STDERR] 	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:290)
09:49:04,328 ERROR [STDERR] 	... 70 more

Hoffe jemand kann mir helfen
 

Neue Beiträge

Zurück