为什么简单的问题总是报Syntax error on token "{", { expected after this token
importjava.io.Serializable;importjava.util.ArrayList;//importjava.util.Collection;//i...
import java.io.Serializable;
import java.util.ArrayList;
//import java.util.Collection;
//import java.util.Iterator;
import java.sql.*;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class dbbean {
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@133.81.9.101:1521:tongji","tongji","qazwsx");
}
catch(SQLException ce){
ce.printStackTrace();
}
} 展开
import java.util.ArrayList;
//import java.util.Collection;
//import java.util.Iterator;
import java.sql.*;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class dbbean {
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@133.81.9.101:1521:tongji","tongji","qazwsx");
}
catch(SQLException ce){
ce.printStackTrace();
}
} 展开
展开全部
执行语句写在方法里面sai :
public class dbbean {
public Connection getOrcaleConn(){
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@133.81.9.101:1521:tongji","tongji","qazwsx");
}
catch(SQLException ce){
ce.printStackTrace();
}
return con;
}
}
public class dbbean {
public Connection getOrcaleConn(){
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@133.81.9.101:1521:tongji","tongji","qazwsx");
}
catch(SQLException ce){
ce.printStackTrace();
}
return con;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询