[an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive] (none)
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive] (none)
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive]
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4
Modifiera nedanstående kodstump så att den passar din databas(ändra
lösenord, db-namn, etc.) och provkör det hela. Får du inte det till att
fungera är troligtvis inte Connector/J korrekt installerad. Jag har lagt
.jar-filen i $JAVA_HOME/jre/lib/ext och mina JDBC-apps funkar jättebra.
Hoppas det funkar. Annars får du ropa till så meckar vi lite till :-)
//Daniel
dbTest.java:
import java.sql.*;
public class dbTest {
public static void main(String[] args) throws SQLException {
Connection con = null;
try {
System.out.println("Trying to connect...");
con = getConnection();
System.out.println("Connection made!");
java.sql.Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT customer_id,
customer_name,customer_email FROM customers");
while (rs.next()) {
// retrieve and print the values for the current row
int i = rs.getInt("customer_id");
String s = rs.getString("customer_name");
String f = rs.getString("customer_email");
System.out.println("ROW = " + i + " " + s + " " + f);
}
} finally {
if (con != null) {System.out.println("Closing
connection.");con.close();}
}
System.out.println("Over and out.");
}
try {
Class.forName(dbDriver).newInstance();
} catch(Exception e) {
throw new SQLException("Class not found: "+e.getMessage());
}
con = DriverManager.getConnection(dbURL,dbUser,dbPass);
return con;
}
}
--
Excuse me, I believe you have my stapler...?
Allan Nielsen wrote:
Hej
Nogle der har prøvet at bruge en mysql database i java, jeg har prøvet
at følge guiden på:
http://www.thep.lu.se/~nicklas/base2/prototype/mysql.html
uden held, jeg tror ikke jeg får installeret pakken fra mysqls hjemme
side rigtig.
Hvis der er nogle som har nogle eksempler/erfaringer/forslag ville dette
være en stor hjælp
Last modified
2005-08-10, 22:43 CEST
[an error occurred while processing this directive] This page is maintained by
[an error occurred while processing this directive]MHonArc
[an error occurred while processing this directive] #
[an error occurred while processing this directive] *