| |

VerySource

 Forgot password?
 Register
Search
Author: yiweilisa

Novice help: java can access the contents of the table when connected with jdbc in java, why is the result not displayed

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 12:15:01
| Show all posts
Print out the exception and see
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-31 12:30:01
| Show all posts
1. See exception information
2. Is there a JAR package for connecting data under the project you released

This post is too long, can it end? ?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 12:45:01
| Show all posts
Post exception, see if it is the error!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 13:15:01
| Show all posts
[code=Java]
while(rs.next())
    {
        out.print( "<TR><TD> "+rs.getString(1)+ "</TD></TR> ");
                                
    }
...
</table>
</body>
</html>
[/code]
html not done well
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 13:30:01
| Show all posts
[color=#FF0000]The HTML markup is wrong[/color]
out.print( "<TR> ");
while(rs.next())
                        {
                                out.print( "<TD> "+rs.getString(1)+" </TD> ");
                                
                        }
rs.close();

out.print( "</TR> ");

out.print( "</table>");
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 13:45:01
| Show all posts
Incorrect HTML markup:
[code=Java]
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs "; //Remove the space after pubs

int temp = 0;

while(rs.next()) {
     if (temp% 5 == 0) {
         out.print( "<TR>");
     }
     out.print( "<TD> "+rs.getString(1)+" </TD> ");
     if ((temp + 1)% 5 == 0) {
         out.print( "</TR>");
     }
     temp++;
}
out.print( "</TABLE>");
[/code]
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 14:00:01
| Show all posts
Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

changed to
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from students ");
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 14:30:01
| Show all posts
Haha, if you look at the original code of that jsp on the webpage, something must have come out, but it is not displayed on the webpage.
The reason is that there is a problem with tr and td of your table.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 15:45:01
| Show all posts
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE
This is wrong,
Change to ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-31 16:00:01
| Show all posts
[Quote=Quote the reply fromloveyanyanon the 1st floor:]
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE
This is wrong,
Change to ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY
[/Quote]

It should be this problem!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list