Results 1 to 11 of 11
Thread: Proble with connect
- 06-13-2010, 08:17 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Proble with connect
import java.sql.*;
public class JDBCConnectionExample {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=NovaBaza;integratedSecurity=false;us er=sa;password=javajdbc";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
con = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns a
// set of data and then display it.
//String SQL = "SELECT * FROM BLOBTest;";
//stmt = con.createStatement();
//rs = stmt.executeQuery(SQL);
//displayRow("Ident", rs);
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
finally {
if (rs != null) try { rs.close(); } catch(Exception e) {}
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
if (con != null) try { con.close(); } catch(Exception e) {}
}
//private static void displayRow(String title, ResultSet rs) {
try {
/// System.out.println(title);
// while (rs.next()) {
// System.out.println(rs.getString());
// }
} catch (Exception e) {
e.printStackTrace();
}
}
}
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at JDBCConnectionExample.main(JDBCConnectionExample.j ava:22)
!MS SQL Server 2005- please nedd help
- 06-13-2010, 09:56 AM #2
Member
- Join Date
- Jun 2010
- Location
- Berlin
- Posts
- 22
- Rep Power
- 0
First of all, why have you put this into a new thread? You've started your post right here http://www.java-forums.org/database/...onnection.html and should go on there.
Then I mentioned before, that if you want someone to help you, you should first invest some time and at least use the CODE tags to mark the code as such and format the code so it could be read more easy.
And if you want help, than ask a question. No one will guess what
means. Is "!MS SQL Server" equal to "not MS SQL Server"? That you need help is obvious while you created a post, but where are some lines what you have done (and why) and what is not working correctly? It doesn't take too much time to put this into one or two sentences, does it?
The error message "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver" tries to tell you something, so what do you think might be the problem? (I am willing to help you, but you must be willing to keep the post more clean and maybe starting by doing some search, googling as well as inside the forum). If you don't find anyone with the same problem, just be so kind and mention what you've tried before.
- 06-13-2010, 01:37 PM #3
The JVM is telling you it can not find a class. Where is that class defined? Probably in a jar file. Find that jar file and add it to the classpath for the JVM.java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
- 06-13-2010, 01:43 PM #4
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Herrk!
I need one simply programm connecting to sql database, please.
- 06-13-2010, 01:55 PM #5
Your program might work if you give it the libraries it needs.
- 06-13-2010, 04:09 PM #6
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Hi Norm!
"Your program might work if you give it the libraries it needs."
1. what libraries;
2. whre I give?
Will you help me please.
- 06-13-2010, 04:43 PM #7
The missing class file "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
" is probably in a jar file(library). You need to find that jar file and put it on the classpath for the java program.
Where did you get the program you're trying to execute? Ask the author of the program where to get the library.
- 06-13-2010, 05:58 PM #8
Member
- Join Date
- Jun 2010
- Location
- Berlin
- Posts
- 22
- Rep Power
- 0
Have you ever simple googled "com.microsoft.sqlserver.jdbc.SQLServerDriver" ? My first result is a real good description by MS which explains how to connect to a MS SQL Server and includes sample code as well....
PS.: If you google "jdbc driver mssql" (without the quotes!) you will get to the MS download page, where the corresponding .jar could be downloaded. The other side descripes how to include the driver into the CLASSPATHLast edited by HerrK.; 06-13-2010 at 06:01 PM.
- 06-13-2010, 06:02 PM #9
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Hi Norm!
Will you send me one simple programm code connecting to sql server 2005database, please.
- 06-13-2010, 06:04 PM #10
Sorry, I do not have any programs like that.
You'd still need the library with the missing class file.
- 06-13-2010, 10:28 PM #11
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Connect Four
By chick in forum New To JavaReplies: 3Last Post: 05-04-2010, 04:33 AM -
Connect 4
By pansylea in forum New To JavaReplies: 0Last Post: 12-11-2009, 03:36 PM -
Proble with poi 3.1 while using CreateDrawingPatrich() method to add images into exc
By chaitudnvr@gmail.com in forum Advanced JavaReplies: 1Last Post: 05-11-2009, 01:13 PM -
how to connect with my GUI
By doha786 in forum New To JavaReplies: 2Last Post: 04-01-2009, 04:59 PM -
Proble displaying images dynamically in jsp
By javaxprogrammer in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-09-2009, 08:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks