Results 1 to 6 of 6
Thread: connecting to a database
- 08-10-2007, 05:08 PM #1
Member
- Join Date
- Aug 2007
- Posts
- 2
- Rep Power
- 0
connecting to a database
this is probably a really stupid question, but this i my first time working with databases so here it goes. I'm trying to connect to a database using the following code:
I keep getting this error however - Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection..Java Code:Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String url = "jdbc:sqlserver://localhost:1433;database=tempdb;"; String user = "sa"; String pw = ""; Connection con = DriverManager.getConnection( url, user, pw );
I've checked the database and this is deffinitely a valid username. I've also tried several other databases with various usernames and i keep getting the same error.
Is there something horribly wrong with my code? Please help
- 12-05-2007, 04:14 PM #2
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:dsname" ,"username","password");
- 08-20-2008, 05:59 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 13
- Rep Power
- 0
hello you must make odbc and:
Connection cn=null;
Statement stm=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbcdbc:database name");
stm=cn.createStatement(ResultSet.TYPE_SCROLL_SENSI TIVE,
ResultSet.CONCUR_UPDATABLE);
JOptionPane.showMessageDialog(null,"connected");
}catch(Exception e)
{JOptionPane.showMessageDialog(null,"eroor" +"\n"+e.getMessage());
}
- 09-08-2009, 07:35 AM #4
Member
- Join Date
- Sep 2009
- Location
- Gurgoan
- Posts
- 4
- Rep Power
- 0
when jsp with sqlserver2005 on netbeans on glassfish server then send a error message my page is not connected so tell me how can do this and also say how i configure tomcat6.0 with netbeans it also send error that not find catalina.bat and myclasspath.bat file
- 09-08-2009, 07:44 AM #5
Member
- Join Date
- Sep 2009
- Location
- Gurgoan
- Posts
- 4
- Rep Power
- 0
jsp with sqlserver on netbeans
databsase is not doing well on my page and servlet page occured error
like org.apache.jaspre......something
- 09-08-2009, 08:39 AM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Connecting to a database
By peiceonly in forum New To JavaReplies: 2Last Post: 04-06-2008, 02:28 PM -
problem in connecting to mysql database
By nancyv in forum Java ServletReplies: 6Last Post: 04-02-2008, 11:33 AM -
Specifying the character set while connecting to the database
By Java Tip in forum Java TipReplies: 0Last Post: 02-13-2008, 11:26 AM -
Error while connecting to a database
By Fukushuusha in forum JDBCReplies: 2Last Post: 12-16-2007, 09:40 AM -
connecting to mysql database
By javagal in forum NetBeansReplies: 2Last Post: 08-04-2007, 12:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks