

Home
Frequently Asked Questions
SQL
This page answers common questions related to the SQL services offered at CSIS.
Please note that there are many variants of SQL. You should always consult product-specific documentation when working with SQL.
A: There are actually many ways to connect to an Oracle database but at Pace we use sqlplus. If you are using the oracle database associated with vulcan.seidenberg.pace.edu you will connect to the oracle database in the following manner:
$ sqlplus username/password@apollo
A: There are many ways to connect to a MySQL database but at Pace we use the standard utility mysql. If you are using the MySQL database associated with vulcan.seidenberg.pace.edu, you will connect to the MySQL database in the following manner:
$ mysql -u username -p
After you have successfully logged in, you must connect to a specific database instance. If you are using the MySQL database associated with vulcan.seidenberg.pace.edu, type the following:
mysql> connect db_instance
** Where db_instance is the database instance assigned to you by your
professor.
|
|
Therefore, you will use a connection string similar to the following to connect to the database server associated with http://vulcan.seidenberg.pace.edu
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); String dbURL="jdbc:oracle:thin:@apollo:1521:ORA1"; Connection conn=DriverManager.getConnection(dbURL,"USERNAME","PASSWORD");Sample Java File
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
import java.math.*;
public class delphi extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException{
PrintWriter out;
out = res.getWriter();
res.setContentType("text/html");
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String dbURL="jdbc:oracle:thin:@apollo:1521:ORA1";
Connection conn=DriverManager.getConnection(dbURL,"username","password");
Statement stmt=conn.createStatement();
ResultSet rset=stmt.executeQuery("SELECT Name,Notes from people");
out.println("<HTML><HEAD><TITLE>DB SERVLET</TITLE></HEAD>");
out.println("<BODY>");
while(rset.next()){
out.println(rset.getString("Name")+" "+rset.getString("Notes"));
out.println("<BR>");
}
rset.close();
stmt.close();
conn.close();
}catch(Exception e){}
out.println("<H1>I added this information!</H1>");
out.println("<BR><H1>I added this line too!</H1>");
out.println("</BODY></HTML>");
out.close();
}
}
A: When logged into the Oracle server, type the following:
| $ >password |
| A: | |
| create table people (name varchar(20), notes varchar(20)); |
| A: | |
| insert into people values ('Tom','Tom works at Pace'); |
| A: | |
| select * from people; |
| A: | |
| update people set name = 'Thomas', notes = 'Thomas works at Pace' where name = 'Tom'; |
| A: | |
| delete people where name = 'Tom'; |
| A: | |
| drop table people; |
A: There is an overwhelming amount of material related to SQL.
Here is an online tutorial that I find helpful for the basics.
You should search for materials that are appropriate for your goals
and projects.
Here are some places to start: