Home > Back-end >  The eclipse problems connecting to the mysql
The eclipse problems connecting to the mysql

Time:11-27

Import the Java. SQL. *;
Public class Example {
Public static void main (String args [])
{
Try
{
Class.forname (". Com. Mysql. Cj. JDBC Driver ");//load the MYSQL JDBC driver
//Class. Class.forname (org. GJT. Mm. Mysql. "Driver");
System. Out.println (" successfully loaded Mysql driver!" );
}
The catch (Exception e)
{
System. The out. Print (" an error occurred when loading the Mysql driver!" );
e.printStackTrace();
}
Try

//JDBC: mysql://localhost: 3306/factory? CharacterEncoding=utf8 & amp; amp; ServerTimezone=UTC
{
The Connection connect=DriverManager. GetConnection (" JDBC: mysql://localhost: 3306/factory? CharacterEncoding=utf8 & amp; amp; ServerTimezone=UTC ", "root", "151994");
//the connection URL for the JDBC: mysql//server/database name, address at the back of the two parameters are respectively login user name and password
System. Out.println (" connect to Mysql server success!" );
The Statement STMT=connect. CreateStatement ();
The ResultSet rs=STMT. ExecuteQuery (" select * from employee where salary> 1900 ");//user the name of the table for you
While (rs), next ())
{
System. The out. Println (rs. Get string (" name "));
}
Connect the close ();
}
The catch (Exception e)
{
System. The out. Print (" to get the data error!" );
e.printStackTrace();
}
}
}
Why the console showed a pile of exception handling loader


On November 26, 2020 9:27:51 morning org. Apache. Catalina. Core. StandardContext backgroundProcess
Warning: exception handling loader [WebappLoader [StandardEngine [r]. Catalina StandardHost [localhost] StandardContext [/222]]] background process
Java. Lang. An IllegalStateException: Java. IO. IOException: Java. Lang. Reflect. InvocationTargetException
The at org. Apache. Catalina. Webresources. AbstractSingleArchiveResourceSet. GetArchiveEntry (AbstractSingleArchiveResourceSet. Java: 101)
The at org. Apache. Catalina. Webresources. AbstractArchiveResourceSet. GetResource (AbstractArchiveResourceSet. Java: 263)
The at org. Apache. Catalina. Webresources. StandardRoot. GetResourceInternal (StandardRoot. Java: 281)
At org. Apache. Catalina. Webresources. Cache. GetResource (62) Cache. Java:
The at org. Apache. Catalina. Webresources. StandardRoot. GetResource (StandardRoot. Java: 216)
The at org. Apache. Catalina. Webresources. StandardRoot. GetClassLoaderResource (StandardRoot. Java: 225)
The at org. Apache. Catalina. Loader. WebappClassLoaderBase. Modified (WebappClassLoaderBase. Java: 740)
The at org. Apache. Catalina. Loader. WebappLoader. Modified (WebappLoader. Java: 362)
The at org. Apache. Catalina. Loader. WebappLoader. BackgroundProcess (WebappLoader. Java: 306)
The at org. Apache. Catalina. Core. StandardContext. BackgroundProcess (StandardContext. Java: 5565)
The at org. Apache. Catalina. Core. ContainerBase $ContainerBackgroundProcessor. ProcessChildren (ContainerBase. Java: 1353)
The at org. Apache. Catalina. Core. ContainerBase $ContainerBackgroundProcessor. ProcessChildren (ContainerBase. Java: 1357)
The at org. Apache. Catalina. Core. ContainerBase $ContainerBackgroundProcessor. ProcessChildren (ContainerBase. Java: 1357)
The at org. Apache. Catalina. Core. ContainerBase $ContainerBackgroundProcessor. Run (ContainerBase. Java: 1335)
The at Java. The base/Java. Util. Concurrent. Executors $RunnableAdapter. Call (515) Executors. Java:
The at Java. The base/Java. Util. Concurrent. FutureTask. RunAndReset (FutureTask. Java: 305)
The at Java. The base/Java. Util. Concurrent. ScheduledThreadPoolExecutor $ScheduledFutureTask. Run (ScheduledThreadPoolExecutor. Java: 305)
The at Java. The base/Java. Util. Concurrent. ThreadPoolExecutor. RunWorker (ThreadPoolExecutor. Java: 1130)
At Java. The base/Java. Util. Concurrent. ThreadPoolExecutor $Worker. The run (ThreadPoolExecutor. Java: 630)
At org, apache tomcat. Util. Threads. TaskThread $WrappingRunnable. Run (61) TaskThread. Java:
At Java. The base/Java. Lang. Thread. The run (832) Thread. Java:
Under Caused by: Java. IO. IOException: Java. Lang. Reflect. InvocationTargetException
At org.apache.tomcat.util.com, pat. Jre9Compat. JarFileNewInstance (Jre9Compat. Java: 209)
At org.apache.tomcat.util.com, pat. JreCompat. JarFileNewInstance (JreCompat. Java: 206)
The at org. Apache. Catalina. Webresources. AbstractArchiveResourceSet. OpenJarFile (AbstractArchiveResourceSet. Java: 314)
The at org. Apache. Catalina. Webresources. AbstractSingleArchiveResourceSet. GetArchiveEntry (AbstractSingleArchiveResourceSet. Java: 97)
. 20 more
Under Caused by: Java. Lang. Reflect. InvocationTargetException
The at Java. The base/JDK. Internal. Reflect. GeneratedConstructorAccessor8. NewInstance (Unknown Source)
The at Java. The base/JDK. Internal. Reflect. DelegatingConstructorAccessorImpl. NewInstance (DelegatingConstructorAccessorImpl. Java: 45)
The at Java. The base/Java. Lang. Reflect the Constructor. NewInstanceWithCaller (500) Constructor. Java:
The at Java. The base/Java. Lang. Reflect the Constructor. NewInstance (481) Constructor. Java:
At org.apache.tomcat.util.com, pat. Jre9Compat. JarFileNewInstance (Jre9Compat. Java: 206)
. 23 more
Under Caused by: Java nio. File. NoSuchFileException: E: \ workshop \. Metadata \. Plugins \ org eclipse WST. Server core \ tmp0 \ wtpwebapps \ \ WEB - 222 INF \ lib \ mysql connector - Java - 5.1.37 - bin. Jar
The at Java. The base/sun. Nio. Fs. WindowsException. TranslateToIOException (WindowsException. Java: 85)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related