0

我是GWT的新手。我正在尝试将我的Oracle10g数据库连接到 GWT 服务器程序,我正在使用以下代码:

public class Database_connect
{   
    public static void connect() 
    {
        System.out.println("This is a test project");
        Connection con=null;

        try 
        {
            Class.forName("oracle.jdbc.OracleDriver");
            System.out.println("Oracle JDBC driver loaded ok.");
            con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","naren", "naren");
            System.out.println("Connected with @localhost:1521:XE.");
            System.out.println("We have done it successfully");
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

    }
}    

在服务器文件中,我正在调用该connect()函数

public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService
{
    public String greetServer(String input) throws IllegalArgumentException 
    {
        Database_connect.connect();
    }
} 

但它显示错误。

我不知道现在该怎么办。任何人都可以帮助我。感谢提前。

错误是

[WARN] failed Server@6e058516
    java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Unknown Source)
    at sun.nio.ch.Net.bind(Unknown Source)
    at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
    at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:205)
    at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:304)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.Server.doStart(Server.java:233)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:836)
    at com.google.gwt.dev.DevMode.main(DevMode.java:311)
[ERROR] shell failed in doStartupServer method
4

1 回答 1

0

我认为您正在运行该项目 2 次..请杀死任务管理器中的所有 Java 进程并仅运行该项目一次..

于 2012-12-26T13:40:49.370 回答