日期:2014-05-20  浏览次数:21004 次

Syntax error on token "}", delete this token 肯定没有少}啊
[code=Java][/code]package com.iotek.test1;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.spi.DirStateFactory.Result;

public class MyTest2 
{

public static void main(String[] args) throws SQLException
{
//装载驱动
try {
Class.forName("org.sqlite.JDBC");
System.out.println("drive loaded");
//建立连接

Connection connection1=DriverManager.getConnection("jdbc:sqlite:e:\\sql\\test2.db");
System.out.println("database connected");

//创建statement
java.sql.Statement stat=connection1.createStatement();

//执行statement
ResultSet resultset=stat.executeQuery(".tables");

//返回结果

catch (ClassNotFoundException e) 
{
e.printStackTrace();
}
}

}


}


java.lang.NoSuchMethodError: main
Exception in thread "main"
提示说是这个

------解决方案--------------------
try{...}catch{...}
catch前少了个
------解决方案--------------------
整下格式就行了。
Java code

public class MyTest2 {

    public static void main(String[] args) throws SQLException{
        //装载驱动
        try {
            Class.forName("org.sqlite.JDBC");
            System.out.println("drive loaded");
            //建立连接
            Connection connection1=
                    DriverManager.getConnection("jdbc:sqlite:e:\\sql\\test2.db");
            System.out.println("database connected");

            //创建statement
            java.sql.Statement stat=connection1.createStatement();

            //执行statement
            ResultSet resultset=stat.executeQuery(".tables");

        }//少了这个}
        catch (ClassNotFoundException e) 
        {
            e.printStackTrace();
        }
    }
}

------解决方案--------------------
catch 之前应有一个 "}". 从后面删除一个 "}".